bin/tmuxs

Sun, 14 Jul 2024 22:56:35 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 14 Jul 2024 22:56:35 -0500
changeset 1175
7907b9c30399
parent 473
049e9d356e16
permissions
-rwxr-xr-x

Add which-key.nvim and descriptions

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
473
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
10 if ! tmux has-session -t "$name" 2>/dev/null; then
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
11 tmux new -d -s "$name"
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
12 fi
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
13
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
14 if [ -n "${TMUX:-}" ]; then
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
15 exec tmux switch-client -t "$name"
448
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 else
473
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
17 exec tmux attach -t "$name"
448
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
473
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
23 tmuxs - tmux session
448
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
473
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
31 # aka: tmuxs quux
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
32
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
33 =head1 DESCRIPTION
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
34
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
35 tmuxs attaches or switches to a session of the given name, or the cwd's name,
049e9d356e16 Fix for new session while in tmux
Meredith Howard <mhoward@roomag.org>
parents: 448
diff changeset
36 creating it if necessary.
448
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37
12d2866f8190 add tmuxs helper
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38 =cut

mercurial