mirror of
https://github.com/pnx/dotfiles
synced 2026-07-03 23:13:39 +02:00
scripts/tmuxs/kill.sh: switch to another session if we are killing the current one
This commit is contained in:
parent
c48615f0ae
commit
75fbfbc6e0
1 changed files with 13 additions and 1 deletions
|
|
@ -1,2 +1,14 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
tmux kill-session -t $(echo $@ | sed 's/: .*//g')
|
|
||||||
|
SESSION=$(echo $@ | sed 's/: .*//g')
|
||||||
|
CURRENT=$(tmux list-sessions -F "#{session_name}" -f "#{session_attached}" | head -n 1)
|
||||||
|
|
||||||
|
# If we are killing the current session. Move to another
|
||||||
|
if [ "$CURRENT" == "$SESSION" ]; then
|
||||||
|
NEXT=$(tmux list-sessions -F "#{session_name}" -f "#{==:#{session_attached},0}" | head -n 1)
|
||||||
|
if [ ! -z "$NEXT" ]; then
|
||||||
|
tmux switch -t "${NEXT}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmux kill-session -t "$SESSION"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue