...
This commit is contained in:
19
examples/tmuxrunnerexamples/functions/tmuxlib.sh
Normal file
19
examples/tmuxrunnerexamples/functions/tmuxlib.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
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"
|
||||
}
|
Reference in New Issue
Block a user