Files
herolib_python/examples/tmuxrunnerexamples/functions/tmuxlib.sh
2025-08-25 07:06:50 +02:00

20 lines
449 B
Bash

get_session() {
local sessions
sessions=$(tmux ls 2>/dev/null | cut -d: -f1)
local count
count=$(echo "$sessions" | wc -l)
if [ "$count" -eq 0 ]; then
echo "Error: no tmux sessions found." >&2
return 1
elif [ "$count" -gt 1 ]; then
echo "Error: more than one tmux session found:" >&2
echo "$sessions" >&2
return 1
fi
export SESSIONNAME="$sessions"
echo "$SESSIONNAME"
}