forked from tmux-plugins/tmux-sidebar
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sidebar.tmux
executable file
·55 lines (48 loc) · 2.14 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
45
46
47
48
49
50
51
52
53
54
55
#!/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 nvim_command="$(nvim_command)"
local tree_nvim_init_file="$(tree_nvim_init_file)"
local editor_nvim_init_file="$(editor_nvim_init_file)"
local python_command="$(python_command)"
local tree_key="$(tree_key)"
local tree_focus_key="$(tree_focus_key)"
local tree_position="$(tree_position)"
local tree_width="$(tree_width)"
local editor_position="$(editor_position)"
local editor_size="$(editor_size)"
local open_focus="$(open_focus)"
local refresh_interval="$(refresh_interval)"
local refresh_interval_inactive_pane="$(refresh_interval_inactive_pane)"
local refresh_interval_inactive_window="$(refresh_interval_inactive_window)"
local enable_debug_pane="$(enable_debug_pane)"
set_tmux_option "${VAR_KEY_PREFIX}-${tree_key}" "${nvim_command},${tree_nvim_init_file},${editor_nvim_init_file},${python_command},${tree_position},${tree_width},${editor_position},${editor_size},${open_focus},${refresh_interval},${refresh_interval_inactive_pane},${refresh_interval_inactive_window},${enable_debug_pane}"
set_tmux_option "${VAR_KEY_PREFIX}-${tree_focus_key}" "${nvim_command},${tree_nvim_init_file},${editor_nvim_init_file},${python_command},${tree_position},${tree_width},${editor_position},${editor_size},${open_focus},${refresh_interval},${refresh_interval_inactive_pane},${refresh_interval_inactive_window},${enable_debug_pane},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
}
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
NEW_PATH="${PATH:+"$PATH:"}$1"
tmux set-environment -g PATH "$NEW_PATH"
fi
}
main() {
set_default_key_binding_options
set_key_bindings
pathadd "$SCRIPTS_DIR/bin"
}
main