-
Notifications
You must be signed in to change notification settings - Fork 7
/
which-key.sh
executable file
·144 lines (137 loc) · 3.96 KB
/
which-key.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env dash
#
# Use dash because of its fast startup time.
#
set -e
script_path="$(readlink -f "$0")"
readonly cmd_show_menu=$script_path
readonly menu_name=${1:-tmux}
readonly plugins_dir="$HOME/.tmux/plugins"
show_menu() {
tmux menu -x R -y P -T "#[align=centre,bold fg=green]$menu_name" "$@"
}
cmd_menu_reopen="run '$cmd_show_menu $menu_name'"
readonly cmd_menu_reopen
case $menu_name in
tmux)
show_menu \
Run space command-prompt \
'Last window' tab last-window \
'Last pane' '`' lastp \
+Copy c "run '$cmd_show_menu Copy'" \
'' \
+Windows w "run '$cmd_show_menu Windows'" \
+Panes p "run '$cmd_show_menu Panes'" \
+Buffers b "run '$cmd_show_menu Buffers'" \
+Sessions s "run '$cmd_show_menu Sessions'" \
+Client C "run '$cmd_show_menu Client'" \
'' \
'Time' T clock-mode \
'Show messages' '~' showmsgs \
+Keys '?' 'list-keys -N'
;;
Copy)
show_menu \
Copy c 'copy-mode' \
'List buffers' '#' lsb
;;
Windows)
show_menu \
Last tab lastw \
Choose w 'choose-tree -Zw' \
Previous p prev \
Next n next \
New c 'neww -c "#{pane_current_path}"' \
'' \
+Layout l "run '$cmd_show_menu Layout'" \
'Split horizontal' / 'splitw -h -c "#{pane_current_path}"' \
'Split vertical ' - 'splitw -v -c "#{pane_current_path}"' \
'Rotate' o rotatew \
'Rotate reverse' O 'rotatew -D' \
'' \
Rename R "command-prompt -I \"#W\" \"renamew -- '%%'\"" \
Kill X 'confirm -p "Kill window #W? (y/n)" killw'
;;
Panes)
show_menu \
Last tab lastp \
Choose p 'displayp -d 0' \
'' \
Left h 'selectp -L' \
Down j 'selectp -D' \
Up k 'selectp -U' \
Right l 'selectp -R' \
'' \
Zoom z 'resizep -Z' \
+Resize r "run '$cmd_show_menu Resize'" \
'Swap left' H 'swapp -L' \
'Swap down' J 'swapp -D' \
'Swap up' K 'swapp -U' \
'Swap right' L 'swapp -R' \
'Break' '!' break-pane \
'' \
Mark m 'selectp -m' \
Unmark M 'selectp -M' \
Capture C capturep \
Respawn R 'confirm -p "Respawn pane #P? (y/n)" "respawnp -k"' \
Kill X 'confirm -p "Kill pane #P? (y/n)" killp'
;;
Resize)
tmux_resize() {
echo resizep "$@" \; "$cmd_menu_reopen"
}
show_menu \
Zoom z 'resizep -Z' \
Left h "$(tmux_resize -L 10)" \
Down j "$(tmux_resize -D 10)" \
Up k "$(tmux_resize -U 10)" \
Right l "$(tmux_resize -R 10)" \
'Left less' H "$(tmux_resize -L)" \
'Down less' J "$(tmux_resize -D)" \
'Up less' K "$(tmux_resize -U)" \
'Right less' L "$(tmux_resize -R)"
;;
Layout)
show_menu \
Next l 'nextl' \
Tiled t 'selectl tiled' \
Horizontal h 'selectl even-horizontal' \
Vertical v 'selectl even-vertical' \
'Horizontal main' H 'selectl main-horizontal' \
'Vertical main' V 'selectl main-vertical'
;;
Buffers)
show_menu \
Choose b 'choose-buffer -Z' \
List l lsb \
Paste p pasteb
;;
Sessions)
show_menu \
Choose s 'choose-tree -Zs' \
New N new \
Rename r rename
;;
Client)
show_menu \
Choose c 'choose-client -Z' \
Last l 'switchc -l' \
Previous p 'switchc -p' \
Next n 'switchc -n' \
'' \
Refresh R refresh \
+Plugins P "run '$cmd_show_menu Plugins'" \
Detach D detach \
'Suspend' Z suspendc \
'' \
'Reload config' r "source $HOME/.tmux.conf \; display \"#{E:'\\ueb37'}\" Config loaded" \
'Customize' , 'customize-mode -Z'
;;
Plugins)
readonly tpm_dir="$plugins_dir/tpm/bindings"
show_menu \
Install i "$tpm_dir/install_plugins" \
Update u "$tpm_dir/update_plugins" \
Clean c "$tpm_dir/clean_plugins"
;;
esac