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

scripts/tmuxs: more improvements

This commit is contained in:
Henrik Hautakoski 2025-11-03 07:24:39 +01:00
parent 5b67d85598
commit 5b322780fc
3 changed files with 32 additions and 5 deletions

View file

@ -1,11 +1,12 @@
#!/usr/bin/env bash
BASE_PATH=$(dirname $(readlink -f $BASH_SOURCE))
source ${BASE_PATH}/helpers.sh
SESSION=$(echo $@ | sed 's/: .*//g')
CURRENT=$(tmux list-sessions -F "#{session_name}" -f "#{session_attached}" | head -n 1)
SESSION=$(echo $@ | get_session_name)
# 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 [ "$(current_session)" == "$SESSION" ]; then
NEXT=$(list_sessions | grep -v "${SESSION}" | head -n 1 | get_session_name)
if [ ! -z "$NEXT" ]; then
tmux switch -t "${NEXT}"
fi