Skip to content

Commit 6c9ec2c

Browse files
authored
Prevent tmux variables from being expanded in Display Menu Commands (#69)
* prevent tmux variables from being expanded * some debugging * debug * removed relative path handler - all input already has this done * updated changelog * explain a filter step * Changed menu names to reflect current hierarchy * Changed param order to match what tmux keybinds reports * using a function to get display command status * removed debugging * linting and removal of dead code * improvements in show_cmd * some debugging * removed that debugging * enabling profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * profiling * removed profiling * removed profiling * clean up som debugging * disabled some debug logging * updsting changelog & readme
1 parent de28b1f commit 6c9ec2c

14 files changed

+271
-135
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented here.
44

55
---
66

7+
## [2.2.3] - 2025-04-28
8+
9+
### Added
10+
11+
- Prevent tmux variables from being expanded in `Display Menu Commands`
12+
13+
### Changed
14+
15+
- Changed titles of some menus to better reflect current placement
16+
- Removed a relative path expander, no longer needed and caused some external
17+
menu actions to fail
18+
19+
---
20+
721
## [2.2.2] - 2025-04-26
822

923
### Changed

README.md

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

2121
## Recent Changes
2222

23-
- Moved Laayouts and Split window into Windows menu
23+
- Prevent tmux variables from being expanded in `Display Menu Commands`
24+
- Moved Layouts and Split window into Windows menu
2425
- Main menu help displays kind of an about box info, about what version of the
2526
plugin is used
2627
- `Display menu commands` Rotates between displaying commands and all matching
2728
prefix and root binds.
2829
- Added parameter `@menus_border_type` for Styling
29-
- Re-factored plugin init
3030

3131
</details>
3232
<details>

items/layouts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static_content() {
3535
#
3636
#===============================================================
3737

38-
menu_name="Layouts"
38+
menu_name="Window Layouts"
3939

4040
# Full path to tmux-menux plugin
4141
D_TM_BASE_PATH="$(dirname -- "$(dirname -- "$(realpath "$0")")")"

items/layouts_indicators.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static_content() {
3232
#
3333
#===============================================================
3434

35-
menu_name="Layouts - Indicators"
35+
menu_name="Layouts - Border Indicators"
3636

3737
# Full path to tmux-menux plugin
3838
D_TM_BASE_PATH="$(dirname -- "$(dirname -- "$(realpath "$0")")")"

items/layouts_lines.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static_content() {
3333
#
3434
#===============================================================
3535

36-
menu_name="Layouts - Lines"
36+
menu_name="Layouts - Border Lines"
3737

3838
# Full path to tmux-menux plugin
3939
D_TM_BASE_PATH="$(dirname -- "$(dirname -- "$(realpath "$0")")")"

items/pane_split.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ static_content() {
1717

1818
set -- \
1919
0.0 S \
20-
2.0 C l "Left" "split-window -hb -c '#{pane_current_path}' $menu_reload" \
20+
2.0 C l "Left" "split-window -bh -c '#{pane_current_path}' $menu_reload" \
2121
1.7 C r "Right" "split-window -h -c '#{pane_current_path}' $menu_reload" \
22-
2.0 C a "Above" "split-window -vb -c '#{pane_current_path}' $menu_reload" \
23-
1.7 C b "Below" "split-window -v -c '#{pane_current_path}' $menu_reload" \
22+
2.0 C a "Above" "split-window -bv -c '#{pane_current_path}' $menu_reload" \
23+
1.7 C b "Below" "split-window -c '#{pane_current_path}' $menu_reload"
2424

2525
menu_generate_part 3 "$@"
2626
}

items/window_split.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ static_content() {
1717

1818
set -- \
1919
0.0 S \
20-
2.0 C l "Left" "split-window -fhb -c '#{pane_current_path}' $menu_reload" \
20+
2.0 C l "Left" "split-window -bfh -c '#{pane_current_path}' $menu_reload" \
2121
1.7 C r "Right" "split-window -fh -c '#{pane_current_path}' $menu_reload" \
22-
2.0 C a "Above" "split-window -fvb -c '#{pane_current_path}' $menu_reload" \
23-
1.7 C b "Below" "split-window -fv -c '#{pane_current_path}' $menu_reload" \
22+
2.0 C a "Above" "split-window -bfv -c '#{pane_current_path}' $menu_reload" \
23+
1.7 C b "Below" "split-window -fv -c '#{pane_current_path}' $menu_reload"
2424

2525
menu_generate_part 3 "$@"
2626
}

scripts/dialog_handling.sh

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ menu_parse() {
335335
alt_command "$label" "$key" "$cmd" "$keep_cmd"
336336
else
337337
mnu_command "$label" "$key" "$cmd" "$keep_cmd"
338-
$b_do_show_cmds && show_cmd "$TMUX_BIN $cmd"
338+
$b_do_show_cmds && sc_show_cmd "$TMUX_BIN $cmd"
339339
fi
340340
;;
341341

@@ -364,19 +364,13 @@ menu_parse() {
364364
# first extract the variables, then if it shouldn't be used move on
365365
! tmux_vers_check "$min_vers" && continue
366366

367-
#
368-
# Expand relative PATH at one spot, before calling the
369-
# various implementations
370-
#
371-
echo "$cmd" | grep -vq / && cmd="$d_scripts/$cmd"
372-
373367
[ -n "$menu_debug" ] && debug_print "key[$key] label[$label] command[$cmd]"
374368

375369
if $cfg_use_whiptail; then
376370
alt_external_cmd "$label" "$key" "$cmd"
377371
else
378372
mnu_external_cmd "$label" "$key" "$cmd"
379-
$b_do_show_cmds && [ "$key" != "!" ] && show_cmd "$cmd"
373+
$b_do_show_cmds && [ "$key" != "!" ] && sc_show_cmd "$cmd"
380374
fi
381375
;;
382376

@@ -874,7 +868,10 @@ ensure_menu_fits_on_screen() {
874868

875869
clear_prep_disp_status() {
876870
safe_now
877-
log_it "Preparing Display Commands took: $(echo "$t_now - $t_show_cmds" | bc)s"
871+
display_command_label
872+
log_it "$(relative_path "$0") - Preparing $_lbl took: $(
873+
echo "$t_now - $t_show_cmds" | bc
874+
)s"
878875

879876
if tmux_vers_check 3.2; then
880877
tmux_error_handler display-message -d 1 ""
@@ -932,19 +929,22 @@ prepare_show_commands() {
932929
# action item
933930
# log_it "prepare_show_commands()"
934931

932+
$all_helpers_sourced || source_all_helpers "prepare_show_commands()"
933+
935934
# Do this before the timer is started, otherwise the first usage of show commands
936935
# will always be slower
937936
$all_helpers_sourced || source_all_helpers "prepare_show_commands"
938937
[ ! -f "$f_cached_tmux_key_binds" ] && {
939938
log_it "Creating: $f_cached_tmux_key_binds"
939+
# Filtering out all key binds displaying a menu, since they won't be relevant
940940
$TMUX_BIN list-keys | grep -iv display-menu >"$f_cached_tmux_key_binds"
941941
}
942942

943943
safe_now t_show_cmds
944944
cfg_use_cache=false
945945
b_do_show_cmds=true
946-
tmux_error_handler display-message "Preparing Display Commands ..."
947-
946+
display_command_label
947+
tmux_error_handler display-message "Preparing $_lbl ..."
948948
# shellcheck source=scripts/show_cmd.sh
949949
. "$D_TM_BASE_PATH"/scripts/show_cmd.sh
950950
}
@@ -954,23 +954,12 @@ display_commands_toggle() {
954954
# log_it "display_commands_toggle($menu_part)"
955955
[ -z "$menu_part" ] && error_msg "add_display_commands() - called with no param"
956956

957-
case "$TMUX_MENUS_SHOW_CMDS" in
958-
"1")
959-
_lbl="Display key binds"
960-
_i=2
961-
;;
962-
"2")
963-
_lbl="Hide key binds"
964-
_i=0
965-
;;
966-
*)
967-
_lbl="Display Commands"
968-
_i=1
969-
;;
970-
esac
957+
# In case we got here via dynamic_content()
958+
$all_helpers_sourced || source_all_helpers "display_commands_toggle()"
971959

960+
display_command_label
972961
set -- \
973-
0.0 E ! "$_lbl" "TMUX_MENUS_SHOW_CMDS=$_i $0"
962+
0.0 E ! "$_lbl_next" "TMUX_MENUS_SHOW_CMDS='$_idx_next' $0"
974963

975964
menu_generate_part "$menu_part" "$@"
976965
}

scripts/helpers_minimal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ error_msg_safe() {
5757
}
5858

5959
source_all_helpers() {
60-
# log_it "[$$] source_all_helpers() - $1"
60+
# log_it_minimal "[$$] source_all_helpers() - $1"
6161
$all_helpers_sourced && {
6262
error_msg_safe "source_all_helpers() called when it was already done - $1"
6363
}

scripts/plugin_init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bind_plugin_key() {
4242
error_msg_safe "Failed to bind trigger: $trigger_sequence"
4343
}
4444

45-
log_it "$trigger_sequence"
45+
log_it_minimal "$trigger_sequence"
4646
}
4747

4848
#===============================================================

0 commit comments

Comments
 (0)