forked from tmux-plugins/tmux-pain-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pain_control.tmux
executable file
·62 lines (54 loc) · 1.69 KB
/
pain_control.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
#!/usr/bin/env bash
default_pane_resize="5"
# tmux show-option "q" (quiet) flag does not set return value to 1, even though
# the option does not exist. This function patches that.
get_tmux_option() {
local option=$1
local default_value=$2
local option_value=$(tmux show-option -gqv "$option")
if [ -z $option_value ]; then
echo $default_value
else
echo $option_value
fi
}
pane_navigation_bindings() {
tmux bind-key a select-pane -L
tmux bind-key C-a select-pane -L
tmux bind-key e select-pane -D
tmux bind-key C-e select-pane -D
tmux bind-key u select-pane -U
tmux bind-key C-u select-pane -U
tmux bind-key o select-pane -R
tmux bind-key C-o select-pane -R
}
window_move_bindings() {
tmux bind-key -r "<" swap-window -d -t -1
tmux bind-key -r ">" swap-window -d -t +1
}
pane_resizing_bindings() {
local pane_resize=$(get_tmux_option "@pane_resize" "$default_pane_resize")
tmux bind-key -r A resize-pane -L "$pane_resize"
tmux bind-key -r E resize-pane -D "$pane_resize"
tmux bind-key -r U resize-pane -U "$pane_resize"
tmux bind-key -r O resize-pane -R "$pane_resize"
}
pane_split_bindings() {
tmux bind-key "|" split-window -h -c "#{pane_current_path}"
tmux bind-key "\\" split-window -fh -c "#{pane_current_path}"
tmux bind-key "-" split-window -v -c "#{pane_current_path}"
tmux bind-key "_" split-window -fv -c "#{pane_current_path}"
tmux bind-key "%" split-window -h -c "#{pane_current_path}"
tmux bind-key '"' split-window -v -c "#{pane_current_path}"
}
improve_new_window_binding() {
tmux bind-key "c" new-window -c "#{pane_current_path}"
}
main() {
pane_navigation_bindings
window_move_bindings
pane_resizing_bindings
pane_split_bindings
improve_new_window_binding
}
main