blob: 8ca6f7a267b01d853efbe597117495b10d6b0351 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
if [ "$1" = '-' ]; then
session="$(cat -)"
if [ -z "$session" ]; then
exit 0
fi
set -- "$session"
fi
if [ ! -d "$1" ]; then
exit 1
fi
if ! session="$(tmux ls -f "#{==:#{session_path},$1}" -F '#S' 2>/dev/null | grep ^)"; then
session="$(tmux new -dc "$1" -PF'#S')"
fi
if [ -z "$TMUX" ]; then
tmux attach-session -t "$session"
else
tmux switch-client -t "$session"
fi
|