Skip to content

Commit 13fb173

Browse files
authored
New feature - Display commands (#60)
* Moved custom_index_template to templates/ * Since its not a config variable, renamed to better fit purpose cfg_log_file_forced -> log_file_forced * various small fixes * Display menu commands * fixed menu_reload
1 parent 2246ef3 commit 13fb173

36 files changed

+417
-178
lines changed

README.md

Lines changed: 118 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ experienced users, then add more for newbies.
2020

2121
## Recent Changes
2222

23+
- Added new feature Display Commands, see `Display menu commands` in the Configuration
24+
section
25+
- Fixed handling of menu options in tmux 3.0 - 3.2a since they don't return an
26+
error for missing options
27+
- Added display commands feature, see Display menu commands section in
2328
- Removed all jk shortcuts in menus, allowing for consistent vim style navigation.
2429
- Plugin is initialized in the background, to cut down on tpm processing time.
25-
- Further optimized caching, cutting rendeing times in half.
2630

2731
</details>
2832
<details>
@@ -144,63 +148,6 @@ Manager](https://github.com/tmux-plugins/tpm).
144148

145149
The plugin should now be activated.
146150

147-
</details>
148-
<details>
149-
<summary>Using Styling for menus</summary>
150-
<br>
151-
152-
### Using Styling for menus
153-
154-
See [docs/Styling.md](docs/Styling.md)
155-
156-
</details>
157-
<details>
158-
<summary>Custom menus</summary>
159-
<br>
160-
161-
## Custom Menus
162-
163-
While the initial assumption was that users wanting to modify the menus would fork
164-
the repository and make changes directly, a feature was added to allow menus to
165-
be added dynamically based on user requests.
166-
167-
For details on how to use this feature, see the documentation:
168-
[docs/CustomMenus.md](docs/CustomMenus.md)
169-
170-
</details>
171-
<details>
172-
<summary>whiptail / dialog</summary>
173-
<br>
174-
175-
## whiptail / dialog - alternate tools for displaying menus
176-
177-
For tmux < 3.0 the tmux feature`display-menu` is not available.
178-
179-
If found `whiptail` or `dialog` will be used to display menus.
180-
181-
The preferred option is whiptail, but if not found dialog will be used instead.
182-
If neither is available, this plugin will abort displaying an error message.
183-
184-
Since these are full-screen apps, when either is used, the current (if any)
185-
task is suspended, dialogs are run, and when done the suspended task is reactivated.
186-
187-
The menu system works the same using external menu handlers, however the menu
188-
shortcuts are not as convenient, since they do not differentiate between upper
189-
and lower case letters,
190-
and does not at all support special keys like 'Left' or 'Home'
191-
192-
To use external dialog handling on modern tmuxes set this env variable:
193-
194-
- for `whiptail` use `export TMUX_MENUS_HANDLER=1`
195-
- for `dialog` use `export TMUX_MENUS_HANDLER=2`
196-
197-
In most cases whiptail is installed by default on Linux distros. If not, install
198-
it using the package manager.
199-
One gotcha is that in the Red Hat universe the package is not called whiptail,
200-
the package containing whiptail is called `newt`.
201-
202-
MacOS does not come with whiptail, but it is available in the Homebrew package `newt`.
203-
204151
</details>
205152
<details>
206153
<summary>Configuration</summary>
@@ -239,18 +186,35 @@ as well as when not using quotes.
239186

240187
### Display without using prefix
241188

242-
In order to trigger menus without first hitting `<prefix>`
243-
244189
```tmux
245190
set -g @menus_without_prefix 'Yes'
246191
```
247192

248-
This boolean parameter can be either `Yes` or `No` (the default)
193+
This boolean parameter defaults to `No`
194+
195+
Use this in order to trigger menus without first hitting `<prefix>`
196+
197+
### Pointer to the config file
198+
199+
```tmux
200+
set -g @menus_config_file '~/.configs/tmux.conf'
201+
```
202+
203+
In the main menu, the tmux config file to be reloaded.
204+
The default location for this is:
205+
206+
1. `@menus_config_file` - if this is defined in the tmux config file, it will be used.
207+
2. `$TMUX_CONF` - if this is present in the environment, it will be used.
208+
3. `$XDG_CONFIG_HOME/tmux/tmux.conf` - if `$XDG_CONFIG_HOME` is defined.
209+
4. `~/.tmux.conf` - Default if none of the above are set.
210+
211+
When a reload is requested, the conf file will be prompted for, defaulting
212+
to the first match above. It can be manually changed.
249213

250214
### Menu location
251215

252-
The default locations are: `C` for tmux >= 3.2 `P` otherwise. If whiptail/dialog is used,
253-
menu location is ignored
216+
The default locations are: `C` for tmux >= 3.2 `P` otherwise. If whiptail/dialog
217+
is used, menu location is ignored
254218

255219
```tmux
256220
set -g @menus_location_x 'W'
@@ -271,13 +235,13 @@ The basic options are:
271235

272236
### Disable caching
273237

274-
By default menu items are cached, set this to `No` to disable all caching.
275-
276238
```tmux
277239
set -g @menus_use_cache 'No'
278240
```
279241

280-
This boolean parameter can be either `Yes` (the default) or `No`
242+
This boolean parameter defaults to `Yes`
243+
244+
By default menu items are cached.
281245

282246
Disabling caching also disables the Custom Menus feature.
283247

@@ -296,26 +260,33 @@ that cache item is regenerated.
296260

297261
### Use Hint Overlays
298262

263+
```tmux
264+
set -g @menus_use_hint_overlays 'No'
265+
```
266+
267+
This boolean parameter defaults to `Yes`
268+
299269
Some menu items will display tmux dialogs, where each have their own rather complex
300-
set of special key bindings - choose-buffer, choose-client, choose-tree and customize-mode
270+
set of special key bindings - choose-buffer, choose-client, choose-tree and
271+
customize-mode
301272

302273
When entering such a dialog, per default an overlay will first be presented lisitng
303274
the keys available for that dialog, if it fits on screen.
304275

305276
Use this setting to disable the overlay feature.
306277

307-
```tmux
308-
set -g @menus_use_hint_overlays 'No'
309-
```
310-
311-
This boolean parameter can be either `Yes` (the default) or `No`
312-
313278
If `@menus_use_hint_overlays` is enabled, there is a support option
314-
`@menus_show_key_hints` (defaults to 'No') that also can be toggled. If `@menus_use_hint_overlays`
315-
is disabled, `@menus_show_key_hints` is ignored.
279+
`@menus_show_key_hints` (defaults to 'No') that also can be toggled.
280+
If `@menus_use_hint_overlays` is disabled, `@menus_show_key_hints` is ignored.
316281

317282
#### Show Key Hints
318283

284+
```tmux
285+
set -g @menus_show_key_hints 'Yes'
286+
```
287+
288+
This boolean parameter defaults to `No`
289+
319290
Related to `@menus_use_hint_overlays` Since those key-listings tend to be rather long
320291
they might not fit on screen, and thus be silently skipped.
321292
Enabling this will offer an extra option `Key Hints` on each menu featuring an
@@ -327,37 +298,28 @@ screen is to small, mentioning required screen size.
327298

328299
It will also serve as a hint as to what menu entries are expected to display an overlay.
329300

330-
```tmux
331-
set -g @menus_show_key_hints 'Yes'
332-
```
333-
334-
This boolean parameter can be either `Yes` or `No` (the default)
301+
### Logging
335302

336-
### Pointer to the config file
303+
Per default logging is disabled. If this is desired, provide a log file name
304+
like this:
337305

338306
```tmux
339-
set -g @menus_config_file '~/.configs/tmux.conf'
307+
set -g @menus_log_file '~/tmp/tmux-menus.log'
340308
```
341309

342-
In the main menu, the tmux config file to be reloaded.
343-
The default location for this is:
310+
### Display menu commands
344311

345-
1. `@menus_config_file` - if this is defined in the tmux config file, it will be used.
346-
2. `$TMUX_CONF` - if this is present in the environment, it will be used.
347-
3. `$XDG_CONFIG_HOME/tmux/tmux.conf` - if `$XDG_CONFIG_HOME` is defined.
348-
4. `~/.tmux.conf` - Default if none of the above are set.
349-
350-
When a reload is requested, the conf file will be prompted for, defaulting
351-
to the first match above. It can be manually changed.
312+
```tmux
313+
set -g @menus_display_commands 'Yes'
314+
```
352315

353-
### Logging
316+
This boolean parameter defaults to `No`
354317

355-
Per default logging is disabled. If this is desired, provide a log file name
356-
like this:
318+
If set to true each menu will include an extra item `Display Commands` with the
319+
shortcut `!` pressing this will display what command is used for each action.
357320

358-
```tmux
359-
set -g @menus_log_file '~/tmp/tmux-menus.log'
360-
```
321+
Be aware that the menu will be taller when using this, so make sure the screen is
322+
large enough to display it!
361323

362324
</details>
363325
<details>
@@ -386,6 +348,63 @@ It will also be displayed if the menu is closed right away intentionally
386348
or unintentionally, so there will no doubt sometimes be false positives.
387349
If it doesn't happen the next time the menu is attempted, it can be ignored.
388350

351+
</details>
352+
<details>
353+
<summary>Using Styling for menus</summary>
354+
<br>
355+
356+
## Using Styling for menus
357+
358+
See [docs/Styling.md](docs/Styling.md)
359+
360+
</details>
361+
<details>
362+
<summary>Custom menus</summary>
363+
<br>
364+
365+
## Custom Menus
366+
367+
While the initial assumption was that users wanting to modify the menus would fork
368+
the repository and make changes directly, a feature was added to allow menus to
369+
be added dynamically based on user requests.
370+
371+
For details on how to use this feature, see the documentation:
372+
[docs/CustomMenus.md](docs/CustomMenus.md)
373+
374+
</details>
375+
<details>
376+
<summary>whiptail / dialog</summary>
377+
<br>
378+
379+
## whiptail / dialog - alternate tools for displaying menus
380+
381+
For tmux < 3.0 the tmux feature`display-menu` is not available.
382+
383+
If found `whiptail` or `dialog` will be used to display menus.
384+
385+
The preferred option is whiptail, but if not found dialog will be used instead.
386+
If neither is available, this plugin will abort displaying an error message.
387+
388+
Since these are full-screen apps, when either is used, the current (if any)
389+
task is suspended, dialogs are run, and when done the suspended task is reactivated.
390+
391+
The menu system works the same using external menu handlers, however the menu
392+
shortcuts are not as convenient, since they do not differentiate between upper
393+
and lower case letters,
394+
and does not at all support special keys like 'Left' or 'Home'
395+
396+
To use external dialog handling on modern tmuxes set this env variable:
397+
398+
- for `whiptail` use `export TMUX_MENUS_HANDLER=1`
399+
- for `dialog` use `export TMUX_MENUS_HANDLER=2`
400+
401+
In most cases whiptail is installed by default on Linux distros. If not, install
402+
it using the package manager.
403+
One gotcha is that in the Red Hat universe the package is not called whiptail,
404+
the package containing whiptail is called `newt`.
405+
406+
MacOS does not come with whiptail, but it is available in the Homebrew package `newt`.
407+
389408
</details>
390409
<details>
391410
<summary>Modifications</summary>
@@ -530,8 +549,8 @@ The best way to send feedback is to file an
530549
## Thanks to
531550

532551
- [sumskyi](https://github.com/sumskyi) for notifying me that the boolean check
533-
error message for invalid values lacked the significant info about what variable
534-
contained the incorrect value. Addressed in release 2.0.2
552+
error message for invalid values lacked the significant info about what variable
553+
contained the incorrect value. Addressed in release 2.0.2
535554
- [GaikwadPratik](https://github.com/GaikwadPratik) for notifying me that the
536555
Disable caching feature was broken
537556
- [Tony Soloveyv](https://github.com/tony-sol) for spotting an unintentional

docs/Debugging.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ teh_debug to false.
1616
It will also limit the error_display in case of errors to a one-liner in the log_file
1717
In order not to flood the log with an elaborate error report.
1818

19+
## TMUX_MENUS_SHOW_CMDS
20+
21+
If this is set to 1 menus will always show commands, regardless of what
22+
`@menus_display_commands` is set to.
23+
1924
## TMUX_MENUS_LOGGING_MINIMAL
2025

2126
If set to 1 only errors and menu rendering times will be logged, practicall if

docs/TODO.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Plan
22

3+
## New feature: Show cmds
4+
5+
By pressing `!` for each command in current menu list current binding (if any).
6+
Otherwise show the tmux sequence needed for the command including any support
7+
scripts, but excluding menu reload.
8+
9+
## Currencies - Zloty
10+
11+
The symbol is two chars, so work around the current one char limitation
12+
313
## WhipTail
414

515
- menu_reload is not working, so disabled

items/advanced.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dynamic_content() {
3434
'Prefix key without C- (will take effect imeditally)' \
3535
'run-shell \"$d_scripts/change_prefix.sh %1 $reload_in_runshell\"'"
3636

37-
menu_generate_part 2 "$@"
37+
menu_generate_part 4 "$@"
3838
}
3939

4040
static_content() {
@@ -44,7 +44,11 @@ static_content() {
4444

4545
# 2.7 M M "Manage clients $nav_next" advanced_manage_clients.sh \
4646
set -- \
47-
0.0 M Left "Back to Main menu $nav_home" main.sh \
47+
0.0 M Left "Back to Main menu $nav_home" main.sh
48+
menu_generate_part 1 "$@"
49+
$cfg_display_cmds && display_commands_toggle 2
50+
51+
set -- \
4852
0.0 S
4953

5054
if $cfg_use_whiptail; then
@@ -81,7 +85,7 @@ static_content() {
8185
"$d_hints/choose-client.sh $0"
8286

8387
}
84-
menu_generate_part 1 "$@"
88+
menu_generate_part 3 "$@"
8589

8690
# shellcheck disable=SC2154
8791
set -- \
@@ -91,8 +95,7 @@ static_content() {
9195
1.8 C x "Kill server" "confirm-before -p \
9296
'kill tmux server defined in($TMUX_SOURCE) ? (y/n)' kill-server"
9397

94-
menu_generate_part 3 "$@"
95-
98+
menu_generate_part 5 "$@"
9699
}
97100

98101
#===============================================================

items/currencies.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ static_content() {
3131

3232
set -- \
3333
0.0 M Left "Back to Missing Keys $nav_prev" missing_keys.sh \
34-
0.0 M Home "Back to Main menu $nav_home" main.sh \
34+
0.0 M Home "Back to Main menu $nav_home" main.sh
35+
menu_generate_part 1 "$@"
36+
$cfg_display_cmds && display_commands_toggle 2
37+
38+
set -- \
3539
0.0 S
3640

3741
# how to print?
@@ -54,8 +58,7 @@ static_content() {
5458
0.0 S \
5559
0.0 M H "Help $nav_next" "$d_help/help_currencies.sh $0"
5660

57-
menu_generate_part 1 "$@"
58-
61+
menu_generate_part 3 "$@"
5962
}
6063

6164
#===============================================================

0 commit comments

Comments
 (0)