From 23aacc7e231b5f73745a6ef72abbcdecf193790d Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 11 Dec 2024 01:24:34 -0600 Subject: pkgs/tmux-open: implement persistent tmux sessions by i3/sway workspace --- pkgs/tmux-open/tmux-open.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pkgs/tmux-open/tmux-open.sh (limited to 'pkgs/tmux-open/tmux-open.sh') 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" -- cgit v1.2.3