marleyos/home/tmux/default.nix
punkfairie 3db105a944
🐛 fix(tmux): Set escape time to 0
tmux was hanging for a bit after hitting esc which is really annoying in
nvim.
2024-11-02 13:14:17 -07:00

137 lines
3.2 KiB
Nix

{
pkgs,
config,
...
}: {
programs.tmux = {
enable = true;
rose-pine = {
enable = true;
extraConfig = ''
set -g @rose_pine_host 'on'
set -g @rose_pine_directory 'on'
'';
};
escapeTime = 0;
# Start window & pane numbering at 1.
baseIndex = 1;
# Vi mode.
keyMode = "vi";
customPaneNavigationAndResize = true;
mouse = true;
# Auto-spawn a new session when attaching if none exist.
newSession = true;
# Key used with Ctrl to make the prefix.
shortcut = "a";
plugins = with pkgs.tmuxPlugins; [
{
plugin = resurrect;
extraConfig = ''
set -g @resurrect-capture-pane-contents 'on'
'';
}
{
plugin = continuum;
extraConfig = ''
set -g @continuum-restore 'on'
'';
}
{
plugin = tilish;
extraConfig = ''
# Don't enforce the layout.
set -g @tilish-enforce 'none'
set -g @tilish-project "$HOME/hackin"
set -g @tilish-navigator 'on'
'';
}
{
plugin = vim-tmux-navigator;
}
yank
{
plugin = jump;
extraConfig = ''
set -g @jump-key 's'
'';
}
{
plugin = fingers;
extraConfig = ''
set -g @fingers-jump-key 's'
'';
}
{
plugin = tmux-floax;
extraConfig = ''
set -g @floax-bind 'i'
'';
}
];
extraConfig = ''
# Set repeat timeout so keys can be repeated without the prefix.
set -g repeat-time 1000
# Auto-renumber windows when one is deleted.
set -g renumber-windows 'on'
set -ag terminal-overrides ",*:RGB"
set -g status-position 'top'
### Keybindings ###
# Easy reload config.
bind r source-file ${config.xdg.configHome}/tmux/tmux.conf \; display-message "Reloaded config"
# Better split commands.
bind -N 'vsplit' | split-window -h -c "#{pane_current_path}"
bind -N 'vsplit' \\ split-window -h -c "#{pane_current_path}"
bind -N 'hsplit' - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# Vi-like resizing.
bind -r -N 'Resize pane (left)' M-h resize-pane -L 5
bind -r -N 'Resize pane (down)' M-j resize-pane -D 5
bind -r -N 'Resize pane (up)' M-k resize-pane -U 5
bind -r -N 'Resize pane (right)' M-l resize-pane -R 5
# Even out panes.
bind -N 'Evenly distribute panes' = select-layout -E
# Swap panes.
bind -r -N 'Swap current pane with the next' H swap-pane -U
bind -r -N 'Swap current pane with the previous' L swap-pane -D
# Window switching.
bind -N 'Previous window' Left previous-window
bind -N 'Next window' Right next-window
# Vi copy mode.
unbind [
bind -N 'Enter normal (copy) mode' Escape copy-mode
bind -T copy-mode-vi ? command-prompt -p '?' 'send -X search-backward %1'
bind -T copy-mode-vi / command-prompt -p '/' 'send -X search-forward %1'
bind -T copy-mode-vi q send -X cancel
bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' 'send -X clear-selection' 'send -X cancel'
'';
};
}