init
This commit is contained in:
121
modules/home/tmux.nix
Normal file
121
modules/home/tmux.nix
Normal file
@@ -0,0 +1,121 @@
|
||||
# Tmux configuration module
|
||||
#
|
||||
# Migrated from chezmoi dot_tmux.conf
|
||||
# Uses Home Manager's programs.tmux for declarative configuration
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
|
||||
# Basic settings
|
||||
mouse = true;
|
||||
baseIndex = 1;
|
||||
keyMode = "vi";
|
||||
escapeTime = 0; # From tmux-sensible
|
||||
historyLimit = 50000; # From tmux-sensible
|
||||
|
||||
# Terminal settings
|
||||
terminal = "screen-256color";
|
||||
|
||||
# Plugins managed by Home Manager (replaces TPM)
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
sensible
|
||||
yank
|
||||
{
|
||||
plugin = power-theme;
|
||||
# Note: tmux-power theme is applied automatically
|
||||
}
|
||||
];
|
||||
|
||||
# Extra configuration that can't be expressed via options
|
||||
extraConfig = ''
|
||||
# Terminal overrides for true color support
|
||||
set -ag terminal-overrides ",xterm-256color:RGB"
|
||||
|
||||
# Window settings
|
||||
set -g renumber-windows on
|
||||
set-option -g allow-rename off
|
||||
|
||||
# Key bindings
|
||||
bind q lock-client
|
||||
|
||||
# Unbind defaults we're replacing
|
||||
unbind '"'
|
||||
unbind %
|
||||
|
||||
# Vim-style pane navigation
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
# Pane resizing with repeat
|
||||
bind -r H resize-pane -L 10
|
||||
bind -r J resize-pane -D 10
|
||||
bind -r K resize-pane -U 10
|
||||
bind -r L resize-pane -R 10
|
||||
|
||||
# Attach to current path
|
||||
bind o attach -c "#{pane_current_path}"
|
||||
|
||||
# Open pane in vim
|
||||
bind-key / capture-pane -S -102400 -J \; new-window 'vim -c ":read !tmux save-buffer - ; tmux delete-buffer;" -c ":normal gg" -c ":set buftype=nofile" -c ":silent! ChompWhitespace"'
|
||||
|
||||
# Catppuccin theme settings (kept for reference if switching themes)
|
||||
set -g @catppuccin_date_time "%Y-%m-%d %H:%M"
|
||||
set -g @catppuccin_window_tabs_enabled "on"
|
||||
|
||||
# Copy mode settings (vi mode is set via keyMode option)
|
||||
bind Escape copy-mode
|
||||
unbind [
|
||||
unbind p
|
||||
bind p paste-buffer
|
||||
bind -Tcopy-mode-vi v send -X begin-selection
|
||||
bind -Tcopy-mode-vi y send -X copy-selection
|
||||
bind -Tcopy-mode-vi Escape send -X cancel
|
||||
|
||||
# Pane splitting (using current path)
|
||||
bind - split-window -v -c "#{pane_current_path}"
|
||||
bind | split-window -h -c "#{pane_current_path}"
|
||||
bind C-z resize-pane -Z
|
||||
bind g swap-pane -U
|
||||
bind æ swap-pane -D
|
||||
|
||||
# Smart pane switching with awareness of Vim splits
|
||||
# See: https://github.com/christoomey/vim-tmux-navigator
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
|
||||
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
|
||||
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
|
||||
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
|
||||
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
|
||||
|
||||
# Alt + hjkl for resizing (with vim awareness)
|
||||
bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'resize-pane -L 1'
|
||||
bind -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'resize-pane -D 1'
|
||||
bind -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'resize-pane -U 1'
|
||||
bind -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'resize-pane -R 1'
|
||||
|
||||
# Version-specific bindings for C-\
|
||||
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
|
||||
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
|
||||
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
|
||||
|
||||
# Copy mode pane switching
|
||||
bind-key -T copy-mode-vi 'C-h' select-pane -L
|
||||
bind-key -T copy-mode-vi 'C-j' select-pane -D
|
||||
bind-key -T copy-mode-vi 'C-k' select-pane -U
|
||||
bind-key -T copy-mode-vi 'C-l' select-pane -R
|
||||
bind-key -T copy-mode-vi 'C-\' select-pane -l
|
||||
|
||||
# Utils - lazygit popup
|
||||
bind -r g display-popup -d '#{pane_current_path}' -w80% -h80% -E lazygit
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user