feat(tmuxinator): show popup for choosing session on <prefix>s

This commit is contained in:
Oliver
2025-10-06 13:57:09 +02:00
parent fdf5efedb1
commit 383a900c2d
2 changed files with 42 additions and 0 deletions

40
tmux/bin/fuzzy-switch.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bash
die() {
printf "\n[tmux-fuzzy] %s\n" "$1" >&2
# keep popup visible if we're in a popup
if [ -n "${TMUX:-}" ]; then
printf "Press ENTER to close..."
read -r _ || true
fi
exit 1
}
list_projects() {
tmuxinator list 2>/dev/null \
| sed '1{/tmuxinator projects:/d;}' \
| tr -s '[:space:]' '\n' \
| grep -E '^[[:alnum:]_.:-]+$' \
|| true
}
# unique + sorted
items="$(list_projects | sort -u)"
[ -n "$items" ] || die "No tmuxinator projects found."
sel="$(
printf '%s\n' "$items" | fzf \
--prompt='Project > ' \
--height=100% --layout=reverse \
--print-query --expect=enter
)" || exit 0
key="$(printf '%s\n' "$sel" | sed -n '1p')"
query="$(printf '%s\n' "$sel" | sed -n '2p' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
choice="$(printf '%s\n' "$sel" | sed -n '3p')"
project="${choice:-$query}"
[ -n "$project" ] || exit 0
tmuxinator start "$project"
exit 0

View File

@@ -66,5 +66,7 @@ set -g @plugin 'omerxx/tmux-sessionx'
set -g @plugin 'christoomey/vim-tmux-navigator'
bind-key s display-popup -w 30% -h 30% -E "~/.config/tmux/bin/fuzzy-switch.sh"
# Initialise tmux plugin manager (needs to be at the bottom of the file)
run '~/.config/tmux/plugins/tpm/tpm'