refactor(tmux): session-switcher is now dynamic

Can pass a session name
This commit is contained in:
Sergio Laín 2025-08-27 14:10:57 +02:00
parent 259ad2106c
commit 335db8d4bd
No known key found for this signature in database
GPG key ID: 51BB28D8B42FB438
3 changed files with 19 additions and 14 deletions

View file

@ -62,7 +62,8 @@ bind -r ">" swap-window -d -t +1
bind-key Enter popup -E -h 90% -w 100% -x C -y C "tf" bind-key Enter popup -E -h 90% -w 100% -x C -y C "tf"
# Switch from Notes/Tasks Session with last session # Switch from Notes/Tasks Session with last session
bind-key n run "tmux-notes-switch" bind-key n run "tmux-session-switcher notes-tasks"
bind-key m run "tmux-session-switcher mail"
# Switch to last used panel and zoom # Switch to last used panel and zoom
bind-key Z select-pane -l \; resize-pane -Z bind-key Z select-pane -l \; resize-pane -Z

View file

@ -1,13 +0,0 @@
#!/bin/bash
SESSION_NOTES="notes-tasks"
if [ "$(tmux display-message -p '#S')" == "$SESSION_NOTES" ]; then
tmux switch-client -l &>/dev/null
else
if tmux has-session -t "$SESSION_NOTES" 2>/dev/null; then
tmux switch-client -t "$SESSION_NOTES" &>/dev/null
else
tmuxp load -y "$SESSION_NOTES" &>/dev/null
fi
fi

View file

@ -0,0 +1,17 @@
#!/bin/bash
SESSION_NAME=$1
if [ -z "$SESSION_NAME" ]; then
tmux switch-client -l &>/dev/null
fi
if [ "$(tmux display-message -p '#S')" == "$SESSION_NAME" ]; then
tmux switch-client -l &>/dev/null
else
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
tmux switch-client -t "$SESSION_NAME" &>/dev/null
else
tmuxp load -y "$SESSION_NAME" &>/dev/null
fi
fi