summaryrefslogtreecommitdiff
path: root/pkgs/tmux-open/tmux-open.sh
blob: c6537b7f5d1cece116f05c6ca691a8bfb2b880b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
set -o errexit
set -o nounset
set -o pipefail

workspace="$( \
	@sway@/bin/swaymsg -t get_workspaces \
	| @jq@/bin/jq '.[] | select(.focused==true).name' \
	| cut -d"\"" -f2)"

session="ws$workspace"
if @tmux@/bin/tmux has-session -t "$session" 2>/dev/null && [ -n "$(@tmux@/bin/tmux list-clients -t "$session")" ]; then
	session="$session-$$"
fi

exec @tmux@/bin/tmux new-session -A -s "$session" -e "SWAYSOCK=$SWAYSOCK" -e "DISPLAY=$DISPLAY"