blob: d1e96b66914ba394e564679a4f68892b83a1b483 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/sh
if [ $# -eq 0 ]; then
set -- "$PWD"
elif [ "$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
exec tmux attach-session -t "$session"
else
tmux switch-client -t "$session"
fi
|