forked from tmux-plugins/tmux-sidebar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar.tmux
executable file
·44 lines (37 loc) · 1.19 KB
/
sidebar.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
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPTS_DIR="$CURRENT_DIR/scripts"
source "$SCRIPTS_DIR/helpers.sh"
source "$SCRIPTS_DIR/variables.sh"
source "$SCRIPTS_DIR/tree_helpers.sh"
set_default_key_binding_options() {
local tree_command="$(tree_command)"
local tree_key="$(tree_key)"
local tree_focus_key="$(tree_focus_key)"
local tree_pager="$(tree_pager)"
local tree_position="$(tree_position)"
local tree_width="$(tree_width)"
local tree_usepager="$(tree_usepager)"
local cmd="$tree_command"
if [ "$tree_usepager" == "on" ] ; then
cmd="$tree_command | $tree_pager"
fi
set_tmux_option "${VAR_KEY_PREFIX}-${tree_key}" "$cmd,${tree_position},${tree_width}"
set_tmux_option "${VAR_KEY_PREFIX}-${tree_focus_key}" "$cmd,${tree_position},${tree_width},focus"
}
set_key_bindings() {
local stored_key_vars="$(stored_key_vars)"
local search_var
local key
local pattern
for option in $stored_key_vars; do
key="$(get_key_from_option_name "$option")"
value="$(get_value_from_option_name "$option")"
tmux bind-key "$key" run-shell "$SCRIPTS_DIR/toggle.sh '$value' '#{pane_id}'"
done
}
main() {
set_default_key_binding_options
set_key_bindings
}
main