From f1e3ca6f971c2c5177174896e1fa3e6f695ca2a1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 18 Jun 2023 21:49:04 +0900 Subject: home-manager: manage tmux --- .config/tmux/tmux.conf | 88 -------------------------------------- home-manager/config/tmux/tmux.conf | 83 +++++++++++++++++++++++++++++++++++ home-manager/home.nix | 30 +++++++++++++ setup.sh | 1 - 4 files changed, 113 insertions(+), 89 deletions(-) delete mode 100644 .config/tmux/tmux.conf create mode 100644 home-manager/config/tmux/tmux.conf diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf deleted file mode 100644 index 6d0535f..0000000 --- a/.config/tmux/tmux.conf +++ /dev/null @@ -1,88 +0,0 @@ -################################################################### -# __ __ _ __ # -# | \/ |_ _ | |_ _ __ ___ _ ___ __ ___ ___ _ __ / _| # -# | |\/| | | | | | __| '_ ` _ \| | | \ \/ / / __/ _ \| '_ \| |_ # -# | | | | |_| | | |_| | | | | | |_| |> < | (_| (_) | | | | _| # -# |_| |_|\__, | (_)__|_| |_| |_|\__,_/_/\_(_)___\___/|_| |_|_| # -# |___/ # -################################################################### - -# OPTIONS {{{1 - -# BASICS {{{2 -set-option -g base-index 1 -set-option -g pane-base-index 1 -set-option -g renumber-windows on -set-option -g history-limit 10000 -set-option -g focus-events on -set-option -g escape-time 10 - -# TERMINAL FEATURES {{{2 -set-option -g default-terminal tmux-256color -set-option -ga terminal-overrides ',tmux-256color:Tc' -set-option -ga terminal-overrides ',alacritty:RGB' - -# APPEARANCE {{{2 -set-option -g status-justify left -set-option -g status-style 'fg=#b1b1c8 bg=#101020' -set-option -g status-left '#{?#{==:#{pane_mode},copy-mode},#[bg=#deab52] COPY ,#[bg=#6e6eff] TMUX }' -set-option -g status-left-length 20 -set-option -g status-left-style 'fg=#101020 bold' -set-option -g status-position top -set-option -g status-right ' %F (%a) %R ' -set-option -g status-right-length 25 -set-option -g status-right-style 'fg=#b1b1c8 bg=#353535' -set-option -g window-status-separator '' -set-option -g window-status-format ' #W ' -set-option -g window-status-style 'fg=#8686bf bg=#101020' -set-option -g window-status-current-format ' #W ' -set-option -g window-status-current-style 'fg=#b1b1c8 bg=#353535' - -set-option -g pane-border-lines single - - -# KEY BINDINGS {{{1 - -unbind-key -a -T root -unbind-key -a -T prefix - -set-option -g status-keys emacs -set-option -g prefix C-t - -bind-key : command-prompt -bind-key ';' command-prompt -bind-key ? list-keys - -# Window -bind-key t new-window -bind-key n next-window -bind-key p previous-window -bind-key N move-window -a -bind-key P move-window -b - -# Pane -bind-key w switch-client -T tw -bind-key -T tw h split-window -h -b -bind-key -T tw j split-window -v -bind-key -T tw k split-window -v -b -bind-key -T tw l split-window -h -bind-key h select-pane -L -bind-key j select-pane -D -bind-key k select-pane -U -bind-key l select-pane -R -bind-key g display-panes -d 0 - -# Layout -bind-key = select-layout tiled -bind-key 4 split-window \; \ - split-window \; \ - split-window \; \ - select-layout tiled - -set-option -g mode-keys vi -bind-key V copy-mode -bind-key -T copy-mode-vi V send-keys -X select-line -bind-key -T copy-mode-vi Escape send-keys -X clear-selection -bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" - -bind-key s set-option synchronize-panes diff --git a/home-manager/config/tmux/tmux.conf b/home-manager/config/tmux/tmux.conf new file mode 100644 index 0000000..e1715cd --- /dev/null +++ b/home-manager/config/tmux/tmux.conf @@ -0,0 +1,83 @@ +################################################################### +# __ __ _ __ # +# | \/ |_ _ | |_ _ __ ___ _ ___ __ ___ ___ _ __ / _| # +# | |\/| | | | | | __| '_ ` _ \| | | \ \/ / / __/ _ \| '_ \| |_ # +# | | | | |_| | | |_| | | | | | |_| |> < | (_| (_) | | | | _| # +# |_| |_|\__, | (_)__|_| |_| |_|\__,_/_/\_(_)___\___/|_| |_|_| # +# |___/ # +################################################################### + +# OPTIONS {{{1 + +# BASICS {{{2 +set-option -g renumber-windows on +set-option -g focus-events on + +# TERMINAL FEATURES {{{2 +set-option -ga terminal-overrides ',tmux-256color:Tc' +set-option -ga terminal-overrides ',alacritty:RGB' + +# APPEARANCE {{{2 +set-option -g status-justify left +set-option -g status-style 'fg=#b1b1c8 bg=#101020' +set-option -g status-left '#{?#{==:#{pane_mode},copy-mode},#[bg=#deab52] COPY ,#[bg=#6e6eff] TMUX }' +set-option -g status-left-length 20 +set-option -g status-left-style 'fg=#101020 bold' +set-option -g status-position top +set-option -g status-right ' %F (%a) %R ' +set-option -g status-right-length 25 +set-option -g status-right-style 'fg=#b1b1c8 bg=#353535' +set-option -g window-status-separator '' +set-option -g window-status-format ' #W ' +set-option -g window-status-style 'fg=#8686bf bg=#101020' +set-option -g window-status-current-format ' #W ' +set-option -g window-status-current-style 'fg=#b1b1c8 bg=#353535' + +set-option -g pane-border-lines single + + +# KEY BINDINGS {{{1 + +unbind-key -a -T root +unbind-key -a -T prefix + +set-option -g status-keys emacs + +bind-key : command-prompt +bind-key ';' command-prompt +bind-key ? list-keys + +# Window +bind-key t new-window +bind-key n next-window +bind-key p previous-window +bind-key N move-window -a +bind-key P move-window -b + +# Pane +bind-key w switch-client -T tw +bind-key -T tw h split-window -h -b +bind-key -T tw j split-window -v +bind-key -T tw k split-window -v -b +bind-key -T tw l split-window -h +bind-key h select-pane -L +bind-key j select-pane -D +bind-key k select-pane -U +bind-key l select-pane -R +bind-key g display-panes -d 0 + +# Layout +bind-key = select-layout tiled +bind-key 4 split-window \; \ + split-window \; \ + split-window \; \ + select-layout tiled + +set-option -g mode-keys vi +bind-key V copy-mode +bind-key -T copy-mode-vi V send-keys -X select-line +bind-key -T copy-mode-vi Escape send-keys -X clear-selection +# This is configured by home-manager. +# bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "" + +bind-key s set-option synchronize-panes diff --git a/home-manager/home.nix b/home-manager/home.nix index c24fb0a..ddbcac9 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -53,4 +53,34 @@ in enable = true; nix-direnv.enable = true; }; + + programs.tmux = { + enable = true; + + sensibleOnTop = false; + + aggressiveResize = true; + baseIndex = 1; + clock24 = true; + escapeTime = 0; + historyLimit = 50000; + mouse = false; + prefix = "C-t"; + terminal = "tmux-256color"; + + extraConfig = ( + let + commonConfig = builtins.readFile ./config/tmux/tmux.conf; + extraConfig = if isWayland then + '' + bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "wl-copy" + '' + else + '' + bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" + ''; + in + commonConfig + extraConfig + ); + }; } diff --git a/setup.sh b/setup.sh index f21acf3..dfbfe0a 100755 --- a/setup.sh +++ b/setup.sh @@ -60,7 +60,6 @@ for name in \ git \ newsboat \ nvim \ - tmux \ ; \ do if [ ! -L ~/.config/"$name" ]; then -- cgit v1.2.3-70-g09d2