forked from treyhunner/tmuxstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmuxstart
executable file
·37 lines (32 loc) · 984 Bytes
/
tmuxstart
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
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# Some helper functions for simpler session files
new_session() { tmux new-session -d -s $session "$@"; }
new_window() { tmux new-window -d -t $session "$@"; }
send_keys() { tmux send-keys -t $session:"$@"; }
select_window() { tmux select-window -t $session:"$@"; }
select_pane() { tmux select-pane -t $session:"$@"; }
set_env() { tmux set-environment -t $session "$@"; }
split() { tmux split-window -t $session:"$@"; }
swap() { tmux swap-pane -t $session:"$@"; }
usage() {
echo "Usage: $0 tmux-session"
}
# Print usage information if there's not exactly 1 argument
[ $# -ne 1 ] && usage && exit 1
session=$1
sessiondir=${TMUXSTART_DIR:-$HOME/.tmuxstart}
TMUX_OLD=$TMUX
TMUX=
if ! tmux has-session -t $session ; then
if [ -f "$sessiondir/$1" ] ; then
. "$sessiondir/$1"
else
tmux new-session -d -s $session
fi
fi
if [ "$TMUX_OLD" = "" ]; then
tmux attach-session -t $session
else
tmux switch-client -t $session
fi
TMUX=$TMUX_OLD