summaryrefslogtreecommitdiff
path: root/pkgs/tmux-open/tmux-open.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tmux-open/tmux-open.sh')
-rw-r--r--pkgs/tmux-open/tmux-open.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkgs/tmux-open/tmux-open.sh b/pkgs/tmux-open/tmux-open.sh
new file mode 100644
index 0000000..c6537b7
--- /dev/null
+++ b/pkgs/tmux-open/tmux-open.sh
@@ -0,0 +1,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"