summaryrefslogtreecommitdiff
path: root/bin/dmenu/terminal_tmux
blob: a341349693eb2554e98bf7bb568463b1b163c4a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env sh

# A script to open a terminal emulator with a tmux session attached.
# The session name can be supplied, otherwise it is chosen using dmenu.
# If the chosen option is listed as a session, that session is attached.
# If the chosen option is not listed, a new session with that name is created.

# The default terminal is st.
TERMINAL="${TERMINAL:-st}"

if [ -n "$1" ]; then
	chosen="$1"
else
	chosen="$(tmux list-sessions -F \#\{session_name\} | dmenu -p "Choose which tmux session to use")"
fi

[ -z "$chosen" ] || exec $TERMINAL -T "tmux: $chosen" zshrc tmux new -A -s "$chosen"