This commit is contained in:
Andrew Haynes
2026-03-10 12:09:51 -04:00
parent 6fcba0c4ab
commit 89bc50163e
4 changed files with 69 additions and 17 deletions
+36 -2
View File
@@ -1,8 +1,41 @@
#!/usr/bin/env bash
selected="${1:-$(find ~ ~/personal ~/personal/Projects ~/.config -mindepth 1 -maxdepth 2 -type d 2>/dev/null | sort -u | fzf)}"
[[ -z $selected ]] && exit 0
# 1. Get active tmux sessions
sessions=$(tmux list-sessions -F "#S" 2>/dev/null)
# 2. Get directories (Optimized find)
# Adjust -maxdepth to 3 or 4 if you want deeper subfolders
# dirs=$(fd . ~ ~/personal ~/personal/Projects ~/.config --min-depth 1 --max-depth 3 --type d)
dirs=$(find ~ ~/personal ~/personal/Projects ~/.config \
-mindepth 1 -maxdepth 2 \
\( -name ".git" -o -name "node_modules" -o -name ".cache" -o -name "Library" \) -prune \
-o -type d -print 2>/dev/null)
# 3. Combine them and pipe to fzf
# We use printf to ensure they appear as a clean list
selected=$(printf "$sessions\n$dirs" | fzf \
--layout=reverse \
--border=rounded \
--margin=1 \
--padding=1 \
--height=100% \
--prompt="󱇗 " \
--color="bg+:#292e42,bg:#1b1d2b,spinner:#bb9af7,hl:#7aa2f7" \
--color="fg:#c0caf5,header:#7dcfff,info:#bb9af7,pointer:#7dcfff" \
--color="marker:#9ece6a,fg+:#c0caf5,prompt:#bb9af7,hl+:#7aa2f7" \
--preview '[[ -d {} ]] && ls -p --color=always {} | head -10 || tmux list-windows -t {} 2>/dev/null' \
--preview-window="top:35%:border-bottom")
# selected=$(printf "$sessions\n$dirs" | fzf \
# --height=100% --layout=reverse --border \
# --prompt="󱇗 Switch to: " --pointer="󰁔" \
# --color="bg+:#292e42,bg:#1b1d2b,spinner:#bb9af7,hl:#7aa2f7" \
# --color="fg:#c0caf5,header:#7dcfff,info:#bb9af7,pointer:#7dcfff" \
# --color="marker:#9ece6a,fg+:#c0caf5,prompt:#bb9af7,hl+:#7aa2f7" \
# --preview '[[ -d {} ]] && ls -p --color=always {} || tmux list-windows -t {} 2>/dev/null' \
# --preview-window=right:60%)
#
session_name=$(basename "$selected" | tr . _)
if ! tmux has-session -t "$session_name" 2>/dev/null; then
@@ -14,3 +47,4 @@ if [[ -z $TMUX ]]; then
else
tmux switch-client -t "$session_name"
fi