From 0b1f165f85edc2dc60e4b96fa04573f19a5a2ca0 Mon Sep 17 00:00:00 2001 From: Kate Temkin Date: Thu, 22 May 2025 13:11:54 +0200 Subject: [PATCH] misc experimentation~ --- nixos/configuration.linux.nix | 2 + nixos/packages/default.pkgs.nix | 1 + packages/default.nix | 4 + packages/xontrib-prompt-bar.nix | 32 ++++ packages/xontrib-termcolors.nix | 32 ++++ wezterm/wezterm.lua | 269 +++++++++----------------------- xonsh/rc.xsh | 13 +- xonsh/requirements.txt | 4 +- 8 files changed, 155 insertions(+), 202 deletions(-) create mode 100644 packages/xontrib-prompt-bar.nix create mode 100644 packages/xontrib-termcolors.nix diff --git a/nixos/configuration.linux.nix b/nixos/configuration.linux.nix index c59fcaf..ea7de4f 100644 --- a/nixos/configuration.linux.nix +++ b/nixos/configuration.linux.nix @@ -83,6 +83,8 @@ extraPackages = [ deprekages.xontrib-whole-word-jumping deprekages.xontrib-term-integrations + deprekages.xontrib-prompt-bar + deprekages.xontrib-termcolors deprekages.xontrib-sh ]; }; diff --git a/nixos/packages/default.pkgs.nix b/nixos/packages/default.pkgs.nix index 2dea961..337f6c0 100644 --- a/nixos/packages/default.pkgs.nix +++ b/nixos/packages/default.pkgs.nix @@ -121,6 +121,7 @@ with pkgs; deprekages.vja wget wireshark-cli + zellij zstd zip diff --git a/packages/default.nix b/packages/default.nix index 5572f2b..742a349 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -120,12 +120,16 @@ flake-utils.lib.eachDefaultSystem ( # xonsh and xontribs xontrib-whole-word-jumping = callPackage ./xontrib-whole-word-jumping.nix {}; xontrib-term-integrations = callPackage ./xontrib-term-integrations.nix {}; + xontrib-prompt-bar = callPackage ./xontrib-prompt-bar.nix {}; + xontrib-termcolors = callPackage ./xontrib-termcolors.nix {}; xontrib-sh = callPackage ./xontrib-sh.nix {}; xonsh-with-xontribs = pkgs.xonsh.override { extraPackages = pythonPackages: [ xontrib-whole-word-jumping xontrib-term-integrations + xontrib-prompt-bar + xontrib-termcolors xontrib-sh ]; }; diff --git a/packages/xontrib-prompt-bar.nix b/packages/xontrib-prompt-bar.nix new file mode 100644 index 0000000..effac38 --- /dev/null +++ b/packages/xontrib-prompt-bar.nix @@ -0,0 +1,32 @@ +{ + callPackage, + fetchPypi, + python3Packages, + xonsh +}: +let + + # Create a version of xonsh as a python package, + # matching the version installed on the syste, + xonsh-python = callPackage ./xonsh-python-package.nix { inherit xonsh; }; + +in python3Packages.buildPythonPackage rec { + pname = "xontrib_prompt_bar"; + version = "0.5.8"; + format = "pyproject"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-955TqiUm+s/0S2TkaSgyUDe3I5596/A2mHb+SpG0VeA="; + }; + + nativeBuildInputs = with python3Packages; [ + setuptools + wheel + ]; + + buildInputs = with python3Packages; [ + xonsh-python + pdm-pep517 + ]; +} diff --git a/packages/xontrib-termcolors.nix b/packages/xontrib-termcolors.nix new file mode 100644 index 0000000..22abbcb --- /dev/null +++ b/packages/xontrib-termcolors.nix @@ -0,0 +1,32 @@ +{ + callPackage, + fetchPypi, + python3Packages, + xonsh +}: +let + + # Create a version of xonsh as a python package, + # matching the version installed on the syste, + xonsh-python = callPackage ./xonsh-python-package.nix { inherit xonsh; }; + +in python3Packages.buildPythonPackage rec { + pname = "xontrib-termcolors"; + version = "0.2.0"; + format = "pyproject"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-ZaVurvHbHFr0fvIc/MeBVqiYFtcbXcRl41GzgI26cIw="; + }; + + nativeBuildInputs = with python3Packages; [ + setuptools + wheel + ]; + + buildInputs = with python3Packages; [ + xonsh-python + pdm-pep517 + ]; +} diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index 809b9b1..78dd5f6 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -9,228 +9,107 @@ local hostname = wezterm.hostname() config = { - -- Set up our font. - font = wezterm.font_with_fallback({ - "MonoLisa", - "Codicons", - }), - font_size = 14, + -- Set up our font. + font = wezterm.font_with_fallback({ + "MonoLisa", + "Codicons", + }), + font_size = 14, - -- Color scheme stuff. - color_scheme = "Solarized Dark - Patched", + -- Color scheme stuff. + color_scheme = "Solarized Dark - Patched", - -- Generel config. - term = "wezterm", + -- Generel config. + term = "wezterm", - -- Get rid of the annoying update popups we can't do anything about. - check_for_updates = false, + -- Get rid of the annoying update popups we can't do anything about. + check_for_updates = false, - -- Automatically reload our config on changes. - automatically_reload_config = true, + -- Automatically reload our config on changes. + automatically_reload_config = true, - -- Improve tab viewing by disabling native wonk, - -- and make it behave more like Tmux. - use_fancy_tab_bar = false, - tab_bar_at_bottom = true, - tab_max_width = 32, + -- Improve tab viewing by disabling native wonk, + -- and make it behave more like Tmux. + hide_tab_bar_if_only_one_tab = true, + use_fancy_tab_bar = false, + tab_bar_at_bottom = true, + tab_max_width = 32, - -- Disable window styling, where possible. - window_decorations = "NONE", + -- Disable window styling, where possible. + window_decorations = "NONE", - -- Use WebGpu, when we can. - front_end = "WebGpu", + -- Use WebGpu, when we can. + front_end = "WebGpu", - -- Tab bar styling. - colors = { - tab_bar = { - background = "#002b36", - active_tab = { - bg_color = "#073642", - fg_color = "#268bd2", - intensity = "Bold", - }, - inactive_tab = { - bg_color = "#002b36", - fg_color = "#586e75", - }, - new_tab = { - bg_color = "#002b36", - fg_color = "#586e75", - }, - }, - }, + -- Tab bar styling. + colors = { + tab_bar = { + background = "#002b36", + active_tab = { + bg_color = "#073642", + fg_color = "#268bd2", + intensity = "Bold", + }, + inactive_tab = { + bg_color = "#002b36", + fg_color = "#586e75", + }, + new_tab = { + bg_color = "#002b36", + fg_color = "#586e75", + }, + }, + }, - -- Set up multiplexing. - unix_domains = { { name = "unix" } }, - ssh_domains = { - { - name = "trailblazer", - remote_address = "trailblazer", - remote_wezterm_path = "/run/current-system/sw/bin/wezterm", - }, - { name = "valere", remote_address = "valere", remote_wezterm_path = "/run/current-system/sw/bin/wezterm" }, - { name = "hinata", remote_address = "hinata", remote_wezterm_path = "/run/current-system/sw/bin/wezterm" }, - }, + -- Set up multiplexing. + unix_domains = { { name = "unix" } }, + ssh_domains = { + { + name = "trailblazer", + remote_address = "trailblazer", + remote_wezterm_path = "/run/current-system/sw/bin/wezterm", + }, + { name = "valere", remote_address = "valere", remote_wezterm_path = "/run/current-system/sw/bin/wezterm" }, + { name = "hinata", remote_address = "hinata", remote_wezterm_path = "/run/current-system/sw/bin/wezterm" }, + }, - -- Key bindings. - leader = { key = "`" }, - keys = { + keys = { - -- Tmux keybindings: tabs and splits. - { - key = "c", - mods = "LEADER", - action = act.SpawnTab("CurrentPaneDomain"), - }, - { - key = "RightArrow", - mods = "LEADER", - action = act.ActivatePaneDirection("Right"), - }, - { - key = "UpArrow", - mods = "LEADER", - action = act.ActivatePaneDirection("Up"), - }, - { - key = "DownArrow", - mods = "LEADER", - action = act.ActivatePaneDirection("Down"), - }, - { - key = ";", - mods = "LEADER", - action = act.ActivatePaneDirection("Next"), - }, - { - key = "v", - mods = "LEADER", - action = act.SplitVertical({ domain = "CurrentPaneDomain" }), - }, - { - key = "h", - mods = "LEADER", - action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }), - }, - { - key = "5", - mods = "LEADER|SHIFT", - action = act.SplitVertical({ domain = "CurrentPaneDomain" }), - }, - { - key = "'", - mods = "LEADER|SHIFT", - action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }), - }, - { - key = "1", - mods = "LEADER", - action = act.ActivateTab(0), - }, - { - key = "2", - mods = "LEADER", - action = act.ActivateTab(1), - }, - { - key = "3", - mods = "LEADER", - action = act.ActivateTab(2), - }, - { - key = "4", - mods = "LEADER", - action = act.ActivateTab(3), - }, - { - key = "5", - mods = "LEADER", - action = act.ActivateTab(4), - }, - { - key = "6", - mods = "LEADER", - action = act.ActivateTab(5), - }, - { - key = "7", - mods = "LEADER", - action = act.ActivateTab(6), - }, - { - key = "8", - mods = "LEADER", - action = act.ActivateTab(7), - }, - { - key = "9", - mods = "LEADER", - action = act.ActivateTab(8), - }, - { - key = "0", - mods = "LEADER", - action = act.ActivateTab(10), - }, - { - key = "x", - mods = "LEADER", - action = act.CloseCurrentPane({ confirm = true }), - }, - - -- Tmux keybindings: misc. - { - key = "`", - mods = "LEADER", - action = act.SendKey({ key = "`" }), - }, - { - key = "d", - mods = "LEADER", - action = act.DetachDomain("CurrentPaneDomain"), - }, - { - key = "z", - mods = "LEADER", - action = act.TogglePaneZoomState, - }, - - -- Generic customization. - { key = "l", mods = "SHIFT|CTRL", action = "ShowDebugOverlay" }, - { key = "Enter", mods = "ALT", action = "DisableDefaultAssignment" }, - { key = "Enter", mods = "SUPER", action = "ToggleFullScreen" }, - }, + -- Generic customization. + { key = "l", mods = "SHIFT|CTRL", action = "ShowDebugOverlay" }, + { key = "Enter", mods = "ALT", action = "DisableDefaultAssignment" }, + { key = "Enter", mods = "SUPER", action = "ToggleFullScreen" }, + }, } -- -- Font Size Tweaks -- font_overrides = { - miko = 10, - hinata = 16, - valere = 12, - utol = 13, - trailblazer = 11, - kanbaru = 12, - aigis = 12; - komashi = 12; + miko = 10, + hinata = 16, + valere = 12, + utol = 13, + trailblazer = 11, + kanbaru = 12, + aigis = 12, + komashi = 12, } if font_overrides[hostname] ~= nil then - config.font_size = font_overrides[hostname] + config.font_size = font_overrides[hostname] end - -- -- Increase tab bar spacing. -- wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width) - -- Truncate our title so we have room for a padding space at the end. - local title = wezterm.truncate_right(tab.active_pane.title, max_width - 6) - local number = tostring((tab.tab_index + 1) % 10) + -- Truncate our title so we have room for a padding space at the end. + local title = wezterm.truncate_right(tab.active_pane.title, max_width - 6) + local number = tostring((tab.tab_index + 1) % 10) - -- Generate the tab format. - return " " .. number .. ": " .. title .. " " + -- Generate the tab format. + return " " .. number .. ": " .. title .. " " end) -- Windows support. diff --git a/xonsh/rc.xsh b/xonsh/rc.xsh index 5f53823..0c8086a 100644 --- a/xonsh/rc.xsh +++ b/xonsh/rc.xsh @@ -25,8 +25,6 @@ warnings.warn = warn # Xonsh configuration # -# Load our Xonsh extensions. -xontrib load whole_word_jumping coreutils term_integration sh # Squish down long CWD paths, $DYNAMIC_CWD_WIDTH="30%" @@ -58,8 +56,8 @@ def try_source(filename): if path.exists(full_file): if XONSHRC_VERBOSE: - print(f"Sourcing {full_file}!") - aliases.source_alias([full_file]) + print(f"Sourcing {full_file}!") + aliases.source_alias([full_file]) elif XONSHRC_VERBOSE: print(f"Not sourcing {full_file}!") @@ -79,7 +77,6 @@ PATH_ADDS = [] # # Per-platform and per-machine environment. # - try_source(socket.gethostname().split('.')[0]) try_source(sys.platform) @@ -129,3 +126,9 @@ except Exception as e: if XONSHRC_VERBOSE: print("Final color scheme: " + $XONSH_COLOR_STYLE) + +# Prompt config. +#$PROMPT="{YELLOW}{env_name}{RESET}{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} {cwd}{branch_color}{curr_branch: {}}{RESET} {RED}{last_return_code_if_nonzero:[{BOLD_INTENSE_RED}{}{RED}] }{RESET}{BOLD_BLUE}{prompt_end}{RESET}" + +# Load our Xonsh extensions. +xontrib load whole_word_jumping coreutils sh termcolors term_integration diff --git a/xonsh/requirements.txt b/xonsh/requirements.txt index 5fed212..3cfa171 100644 --- a/xonsh/requirements.txt +++ b/xonsh/requirements.txt @@ -1,4 +1,4 @@ xontrib-whole-word-jumping -xontrib-bashisms +xontrib-sh xontrib-term-integrations -xontrib-abbrevs +xontrib-prompt-bar