nix-config/modules/features/programs/cli/cli-tmux.nix
2026-04-20 00:22:19 -04:00

139 lines
4.5 KiB
Nix

{
config,
pkgs,
lib,
...
}:
{
config.dendritic.features.cli-tmux = {
homeModules = [
(
{ config, pkgs, ... }:
{
stylix.targets.tmux.enable = false;
programs.tmux = {
enable = true;
terminal = "xterm-256color";
baseIndex = 1;
escapeTime = 0;
historyLimit = 1000000;
mouse = true;
keyMode = "vi";
shortcut = "b";
plugins = with pkgs.tmuxPlugins; [
vim-tmux-navigator
{
plugin = fzf-tmux-url;
extraConfig = "set -g @fzf-url-fzf-options '-p 60%,30% --prompt=\" \" --border-label=\" Open URL \"'";
}
{
plugin = tmux-floax;
extraConfig = "set -g @floax-bind 'H'";
}
{
plugin = extrakto;
extraConfig = ''
set -g @extrakto_key "tab"
set -g @extrakto_popup_size "50%"
'';
}
{
plugin = tmux-thumbs;
extraConfig = ''
set -g @thumbs-key "F"
set -g @thumbs-command 'echo -n {} | wl-copy'
'';
}
{
plugin = yank;
}
];
extraConfig = ''
set -ga terminal-overrides ",*256col*:Tc"
set -g allow-passthrough on
set -g focus-events on
set -g set-clipboard on
set -g detach-on-destroy off
set -g renumber-windows on
bind-key "T" run-shell "sesh connect \$(
sesh list -tz | fzf-tmux -p 55%,60% \
--no-sort --border-label ' sesh ' --prompt ' ' \
--header ' ^a all ^t tmux ^x zoxide ^f find' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt( )+reload(sesh list)' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z)' \
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
--bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt( )+reload(sesh list)'
)"
bind-key "N" display-popup -E "sesh ui"
bind-key "L" run-shell "sesh last || tmux display-message -d 1000 'Only one session'"
bind -N "+9 switch to root session (via sesh) " 9 run-shell "sesh connect --root \$(pwd)"
bind -N "+^+t join pane" J join-pane -t 1
bind -N "+e editor" E new-window -S -n '📝' 'nvim +GoToFile'
bind -N "+g lazyjj" g new-window -S -n '🌳' 'lazyjj'
bind -N "++Q kill current session" Q kill-session
bind -N "++T break pane" B break-pane
set -g status-interval 3
set -g status-justify absolute-centre
set -g status-position top
set -g status-style 'bg=default'
set -g status-left " #[fg=blue,bold]#S "
set -g status-left-length 300
set -g status-right ""
set -g window-status-current-format '#[fg=magenta]*#W'
set -g window-status-format ' #[fg=gray]#W'
set -g pane-active-border-style 'fg=black,bg=default'
set -g pane-border-style 'fg=brightblack,bg=default'
bind '%' split-window -c '#{pane_current_path}' -h
bind '"' split-window -c '#{pane_current_path}'
bind c new-window -c '#{pane_current_path}'
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key x kill-pane
'';
};
home.packages = with pkgs; [
sesh
fzf
fd
zoxide
lazyjj
];
programs.zsh = {
shellAliases = {
tx = "sesh connect /home/${config.home.username}";
ta = "tmux attach -t";
tad = "tmux attach -d -t";
ts = "tmux new-session -s";
tl = "tmux list-sessions";
tksv = "tmux kill-server";
tkss = "tmux kill-session -t";
};
};
}
)
];
};
}