-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmux-command-menu
More file actions
executable file
·43 lines (34 loc) · 1.17 KB
/
Copy pathtmux-command-menu
File metadata and controls
executable file
·43 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Tmux command menu - dynamically loads keybindings
# Get paths dynamically
FZF=$(command -v fzf)
TMUX_BIN=$(command -v tmux)
# Get all prefix keybindings and format them nicely
bindings=$($TMUX_BIN list-keys -T prefix | awk '{
# Extract the key and command
key = $4
cmd = ""
for (i = 5; i <= NF; i++) cmd = cmd " " $i
gsub(/^[ \t]+/, "", cmd)
# Skip if empty or meta keys
if (key == "" || cmd == "") next
# Format: key → command
printf "%-12s %s\n", key, cmd
}' | sort)
# Show fzf and get selection
selected=$(echo "$bindings" | $FZF \
--reverse \
--border rounded \
--prompt " " \
--pointer " " \
--header "TMUX KEYBINDINGS (prefix + key)" \
--color "pointer:9,spinner:92,marker:46,fg:7,bg:-1,hl:4,fg+:15,bg+:0,hl+:12,info:8,prompt:4,border:8" \
--preview-window hidden)
[[ -z $selected ]] && exit 0
# Extract the command from selection (everything after the key)
cmd=$(echo "$selected" | sed 's/^[^ ]*[ ]*//')
# Write command to temp file and source it - this handles braces and interactive commands
tmpfile=$(mktemp)
echo "$cmd" > "$tmpfile"
$TMUX_BIN source-file "$tmpfile"
rm -f "$tmpfile"