diff options
Diffstat (limited to 'pkgs/tmux-open')
| -rw-r--r-- | pkgs/tmux-open/default.nix | 11 | ||||
| -rw-r--r-- | pkgs/tmux-open/tmux-open.sh | 15 |
2 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/tmux-open/default.nix b/pkgs/tmux-open/default.nix new file mode 100644 index 0000000..3d4f5ce --- /dev/null +++ b/pkgs/tmux-open/default.nix @@ -0,0 +1,11 @@ +{ + jq, + replaceVars, + sway, + tmux, + writeShellScriptBin, + ... +}: +writeShellScriptBin "tmux-open" (builtins.readFile (replaceVars ./tmux-open.sh { + inherit jq sway tmux; +})) 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" |
