bin/tmuxs

Mon, 12 Dec 2016 17:41:33 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 12 Dec 2016 17:41:33 -0500
changeset 448
12d2866f8190
child 473
049e9d356e16
permissions
-rwxr-xr-x

add tmuxs helper

448
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 #!/bin/sh
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 set -eu
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 case ${1:-} in *help|-h)
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 exec perldoc -T $0;;
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 esac
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 name=${1:-$(basename `pwd`)}
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 if tmux ls -F '#S' | grep -x $name >/dev/null; then
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 if [[ ${TMUX:-} ]]; then
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 exec tmux switch-client -t $name
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 else
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14 exec tmux attach -t $name
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 fi
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 else
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 exec tmux new -s $name
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 fi
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 :<<=cut
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 =head1 NAME
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 tmuxs - Start or attach session based on cwd or given name
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25 =head1 SYNOPSIS
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27 tmuxs foobaz
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29 cd ~/proj/quux
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30 tmuxs
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32 =cut

mercurial