tmux: use builtin switch to last session

lol I reinvented the wheel
This commit is contained in:
Primrose 2025-07-16 21:06:01 +02:00
parent 3f46bd7c81
commit 38b704da0e
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
3 changed files with 3 additions and 24 deletions

View file

@ -72,6 +72,9 @@ bind -T copy-mode-vi C-t select-window -t 2
bind -T copy-mode-vi C-n select-window -t 3 bind -T copy-mode-vi C-n select-window -t 3
bind -T copy-mode-vi C-s select-window -t 4 bind -T copy-mode-vi C-s select-window -t 4
# easier to hit than L
bind l switch-client -l
# CLOK # CLOK
bind C-t clock-mode bind C-t clock-mode
set -g clock-mode-style 24 set -g clock-mode-style 24

View file

@ -26,7 +26,6 @@
programs.tmux.extraConfig = lib.mkBefore '' programs.tmux.extraConfig = lib.mkBefore ''
# sessionizer binds # sessionizer binds
bind -n C-f run-shell "tmux new-window tmux-sessionizer" bind -n C-f run-shell "tmux new-window tmux-sessionizer"
bind l run-shell "tmux-last"
''; '';
home.packages = with pkgs; [ home.packages = with pkgs; [

View file

@ -53,28 +53,6 @@
''; '';
}; };
tmux-last = writeShellApplication {
name = "tmux-last";
text = ''
tmux_last=/tmp/TMUX_LAST
if [ ! -f $tmux_last ]; then
echo "Last session is not yet set"
return 1
fi
session_name="$(cat $tmux_last)"
session_path="$session_name"
if [ ! -d "$session_path" ]; then
session_path="/tmp"
fi
# bail if not in tmux, nothing to register
${lib.getExe tmux-register-session} || :
${lib.getExe tmux-maybe-create} "$session_name" "$session_path"
${lib.getExe tmux-attach-or-switch} "$session_name"
'';
};
tmux-sessionizer = writeShellApplication { tmux-sessionizer = writeShellApplication {
name = "tmux-sessionizer"; name = "tmux-sessionizer";
runtimeInputs = [fzf gnused]; runtimeInputs = [fzf gnused];
@ -121,7 +99,6 @@ in
tmux-register-session tmux-register-session
tmux-maybe-create tmux-maybe-create
tmux-attach-or-switch tmux-attach-or-switch
tmux-last
tmux-sessionizer tmux-sessionizer
]; ];
} }