-
Notifications
You must be signed in to change notification settings - Fork 11
/
menus.tmux
executable file
·68 lines (60 loc) · 2.17 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 aproach 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="$(realpath "$(dirname -- "$0")")"
initialize_plugin=1 # tell helpes.sh to replace (potentially) cached params
# 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 tmux_vers_check 3.0 && [ "$FORCE_WHIPTAIL_MENUS" != "1" ]; then
cmd="$d_items/main.sh"
else
[ -z "$(command -v whiptail)" ] && {
tmux_error_handler bind-key "$@" "$cfg_trigger_key" \
display-message "DEPENDENCY: $plugin_name needs whiptail"
error_msg "whiptail is not installed!"
}
cmd="$d_scripts/do_whiptail.sh"
log_it "whiptail will be used"
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
log_it "trigger:[$cfg_trigger_key]"
tmux_error_handler bind-key "$@" "$cfg_trigger_key" run-shell "$cmd"
log_it "$trigger_sequence"