1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14:55 +02:00
dotfiles/scripts/tmuxs/kill.sh

14 lines
445 B
Bash
Executable file

#!/usr/bin/env bash
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"