theniceboy/tmux/scripts/new_session.sh
2026-03-27 21:04:47 -07:00

22 lines
501 B
Bash
Executable file

#!/bin/bash
LOCK="/tmp/tmux-new-session.lock"
current_session_id="${1:-}"
touch "$LOCK"
session_id=$(tmux new-session -d -P -s 'session' -F '#{session_id}' 2>/dev/null)
if [ -z "$session_id" ]; then
rm -f "$LOCK"
exit 0
fi
if [ -n "$current_session_id" ]; then
python3 "$HOME/.config/tmux/scripts/session_manager.py" insert-right "$current_session_id" "$session_id"
else
python3 "$HOME/.config/tmux/scripts/session_manager.py" ensure
fi
rm -f "$LOCK"
tmux switch-client -t "$session_id"