-
Notifications
You must be signed in to change notification settings - Fork 12
/
menus.tmux
executable file
·68 lines (59 loc) · 2.01 KB
/
menus.tmux
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
#!/bin/sh
#
# Copyright (c) 2022-2024: [email protected]
# License: MIT
#
# Part of https://github.com/jaclu/tmux-menus
#
# tmux env is read each time this plugin init script is run, so changes
# in tmux version or your tmux conf file will be detected and trigger
# a cache replacement.
#
# tpm will call this during a tmux source-file call, so this cache can
# be trusted by the menu items to contain current tmux env variables.
#
# One thing to be aware of - If multiple tmux instances of the same version
# use the same folder for this plugin, this cache approach might not work
# as intended, since the tmux env is just read once then this cache is used.
#
# If those tmux instances do not have identical tmux-menus configuration,
# thing will not work as intended.
#
# Therefore each instance using tmux-menus should use a separate folder
# for the plugin, not using soft-links to the same folder!
#
#===============================================================
#
# Main
#
#===============================================================
D_TM_BASE_PATH="$(dirname -- "$(realpath "$0")")"
#
# tell helpers.sh to replace (potentially) cached params
# if tmux version and env variables have not been changed,
# cached menus are not purged.
#
initialize_plugin=1
# shellcheck source=scripts/helpers.sh
. "$D_TM_BASE_PATH"/scripts/helpers.sh
# implied check if caching is used
[ -d "$d_cache" ] && cache_add_ok_vers "$tmux_vers"
if $cfg_use_whiptail; then
cmd="$d_scripts/external_dialog_trigger.sh"
log_it "alternate menu handler: $cfg_alt_menu_handler"
else
cmd="$d_items/main.sh"
fi
# have to use "set --"" in order to send the selected params to tmux
set --
$cfg_use_notes && {
set -- "$@" -N "plugin: $plugin_name trigger"
}
if $cfg_no_prefix; then
set -- "$@" -n
trigger_sequence="Menus bound to: $cfg_trigger_key"
else
trigger_sequence="Menus bound to: <prefix> $cfg_trigger_key"
fi
tmux_error_handler bind-key "$@" "$cfg_trigger_key" run-shell "$cmd"
log_it "$trigger_sequence"