summaryrefslogtreecommitdiff
path: root/.local/bin/fzy-tmux-project
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/fzy-tmux-project')
-rwxr-xr-x.local/bin/fzy-tmux-project15
1 files changed, 15 insertions, 0 deletions
diff --git a/.local/bin/fzy-tmux-project b/.local/bin/fzy-tmux-project
new file mode 100755
index 0000000..b4cd23e
--- /dev/null
+++ b/.local/bin/fzy-tmux-project
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -eu
+
+CONFIG_PATH="$XDG_CONFIG_HOME/fzy-tmux-project"
+
+search_dirs=$(cat "$CONFIG_PATH" | sed "s|~|$HOME|g")
+dir=$(find "$search_dirs" -mindepth 1 -maxdepth 1 -type d | fzy) || exit 0
+[ ! -d "$dir" ] && exit 1
+name=$(basename "$dir" | tr . _)
+
+[ -z "$TMUX" ] && ! pgrep tmux >/dev/null && exec tmux new -s "$name" -c "$dir"
+
+! tmux has -t "$name" 2>/dev/null && tmux new -ds "$name" -c "$dir"
+tmux switchc -t "$name"