From 9129863969373433261ce80a070d1b0f394a150b Mon Sep 17 00:00:00 2001 From: Hare Date: Sun, 4 Jan 2026 01:49:46 +0900 Subject: [PATCH] fish and wezterm --- flake.lock | 6 +- home-manager/fish/default.nix | 6 ++ home-manager/fish/functions/fish_prompt.fish | 41 +++++++++ home-manager/wezterm/default.nix | 6 ++ home-manager/wezterm/wezterm.lua | 88 ++++++++++++++++++++ hosts/arcadia/home-manager.nix | 3 + hosts/fungus/home-manager.nix | 2 + hosts/x1carbon/home-manager.nix | 2 + 8 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 home-manager/fish/default.nix create mode 100644 home-manager/fish/functions/fish_prompt.fish create mode 100644 home-manager/wezterm/default.nix create mode 100644 home-manager/wezterm/wezterm.lua diff --git a/flake.lock b/flake.lock index 1ef8dbb..613d1f9 100644 --- a/flake.lock +++ b/flake.lock @@ -25,11 +25,11 @@ ] }, "locked": { - "lastModified": 1767391542, - "narHash": "sha256-qHXxJuFkQhggyeao/kQb6KcOjgz0Ky+ArfowRX1MHaE=", + "lastModified": 1767437240, + "narHash": "sha256-OA0dBHhccdupFXp+/eaFfb8K1dQxk61in4aF5ITGVX8=", "owner": "nix-community", "repo": "home-manager", - "rev": "2f06b726061b7e1aa69f718e943da9ffcecd6397", + "rev": "1cfa305fba94468f665de1bd1b62dddf2e0cb012", "type": "github" }, "original": { diff --git a/home-manager/fish/default.nix b/home-manager/fish/default.nix new file mode 100644 index 0000000..6aeaa80 --- /dev/null +++ b/home-manager/fish/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + programs.fish.enable = true; + + xdg.configFile."fish/functions/fish_prompt.fish".source = ./functions/fish_prompt.fish; +} diff --git a/home-manager/fish/functions/fish_prompt.fish b/home-manager/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..00d0622 --- /dev/null +++ b/home-manager/fish/functions/fish_prompt.fish @@ -0,0 +1,41 @@ +function preexec --on-event fish_preexec + set -g _play_command_begin_time (date +%s%3N) +end + +function postexec --on-event fish_postexec + set -l _status $status + if test -z $_play_command_begin_time + return + end + + set -l code + if test $_status -eq 0 + set_color green + set code "✔success:$_status" + else + set_color red + set code "✘error:$_status" + end + + set -l took_time + set -l millis (echo (date +%s%3N)"-$_play_command_begin_time" | bc) + if test $millis -ge 10000 + set took_time (echo "$millis/1000" | bc)s + else if test $millis -ge 1000 + set took_time (echo "scale=2; $millis/1000" | bc)s + else + set took_time "$millis""ms" + end + + echo -s -n $code\ (set_color magenta)\ 󱦟$took_time\n +end + +function fish_prompt + set now_date (set_color cyan)(date +%H:%M:%S) + set who_n_where (set_color yellow)$USER::(prompt_hostname) + set pwd (prompt_pwd) + set enter_mark (set_color red)'❯'(set_color yellow)'❯'(set_color green)'❯' + + echo -e -s -n -- $now_date\ $who_n_where\ (set_color white)\|(set_color yellow)\ $pwd\n$enter_mark\ + set_color normal +end diff --git a/home-manager/wezterm/default.nix b/home-manager/wezterm/default.nix new file mode 100644 index 0000000..e785e11 --- /dev/null +++ b/home-manager/wezterm/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + programs.wezterm.enable = true; + + xdg.configFile."wezterm/wezterm.lua".source = ./wezterm.lua; +} diff --git a/home-manager/wezterm/wezterm.lua b/home-manager/wezterm/wezterm.lua new file mode 100644 index 0000000..542222e --- /dev/null +++ b/home-manager/wezterm/wezterm.lua @@ -0,0 +1,88 @@ +local wezterm = require 'wezterm' +local config = { + enable_wayland = true, + force_reverse_video_cursor = true, + + font_size = 12, + + colors = { + foreground = '#dcd7ba', + background = 'rgba(31,31,31,0.2)', + + cursor_bg = '#c8c093', + cursor_fg = '#c8c093', + cursor_border = '#c8c093', + + selection_fg = '#c8c093', + selection_bg = '#2d4f67', + + scrollbar_thumb = '#16161d', + split = '#16161d', + + ansi = { '#090618', '#c34043', '#76946a', '#c0a36e', '#7e9cd8', '#957fb8', '#6a9589', '#c8c093' }, + brights = { '#727169', '#e82424', '#98bb6c', '#e6c384', '#7fb4ca', '#938aa9', '#7aa89f', '#dcd7ba' }, + indexed = { [16] = '#ffa066', [17] = '#ff5d62' }, + tab_bar = { + background = 'rgba(31, 31, 40, 0.5)', + new_tab = { + bg_color = 'rgba(31, 31, 40, 0.5)', + fg_color = '#c8c093', + }, + new_tab_hover = { + bg_color = 'rgba(31, 31, 40, 0.5)', + fg_color = '#c8c093', + intensity = 'Bold' + }, + } + }, + + use_fancy_tab_bar = false, + show_tab_index_in_tab_bar = false, + + keys = { + { key = 'V', mods = 'CTRL', action = wezterm.action.PasteFrom 'Clipboard' }, + } +} + +local SOLID_LEFT_ARROW = wezterm.nerdfonts.pl_right_hard_divider +local SOLID_RIGHT_ARROW = wezterm.nerdfonts.pl_left_hard_divider +function tab_title(tab_info) + local title = tab_info.tab_title + -- if the tab title is explicitly set, take that + if title and #title > 0 then + return title + end + -- Otherwise, use the title from the active pane + -- in that tab + return tab_info.active_pane.title +end +wezterm.on( + 'format-tab-title', + function(tab, tabs, panes, config, hover, max_width) + + local bg_color = 'rgba(31, 31, 40, 0.5)' + local fg_color = '#c8c093' + local text_color = '#1f1f28' + + if tab.is_active then + fg_color = '#2d4f67' + text_color = '#c8c093' + end + + local title = wezterm.truncate_right(tab_title(tab), max_width - 4) + + return { + { Background = { Color = bg_color } }, + { Foreground = { Color = fg_color } }, + { Text = SOLID_LEFT_ARROW }, + { Background = { Color = fg_color } }, + { Foreground = { Color = text_color } }, + { Text = ' ' .. title .. ' ' }, + { Background = { Color = bg_color } }, + { Foreground = { Color = fg_color } }, + { Text = SOLID_RIGHT_ARROW }, + } + end +) + +return config diff --git a/hosts/arcadia/home-manager.nix b/hosts/arcadia/home-manager.nix index 53c8e97..407bffc 100644 --- a/hosts/arcadia/home-manager.nix +++ b/hosts/arcadia/home-manager.nix @@ -13,6 +13,9 @@ ./display.nix + ../../home-manager/wezterm + ../../home-manager/fish + ../../home-manager/vscode.nix ../../home-manager/direnv.nix ../../home-manager/firefox.nix diff --git a/hosts/fungus/home-manager.nix b/hosts/fungus/home-manager.nix index 3822e28..909492b 100644 --- a/hosts/fungus/home-manager.nix +++ b/hosts/fungus/home-manager.nix @@ -3,6 +3,8 @@ home.stateVersion = "25.05"; imports = [ ../../home-manager/direnv.nix + ../../home-manager/wezterm + ../../home-manager/fish ]; home.packages = with pkgs; [ ]; diff --git a/hosts/x1carbon/home-manager.nix b/hosts/x1carbon/home-manager.nix index 07cb0d0..28cc0fd 100644 --- a/hosts/x1carbon/home-manager.nix +++ b/hosts/x1carbon/home-manager.nix @@ -12,6 +12,8 @@ ../../home-manager/fnott.nix ../../home-manager/direnv.nix ../../home-manager/obs-studio.nix + ../../home-manager/wezterm + ../../home-manager/fish ]; hare.hyprland = { style = import ../../home-manager/hyprland/styles/thin.nix { inherit lib; };