Skip to content

Add customize resize values #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions better-vim-tmux-resizer.tmux
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
#!/usr/bin/env bash

# $1: option
# $2: default value
tmux_get() {
local value="$(tmux show -gqv "$1")"
[ -n "$value" ] && echo "$value" || echo "$2"
}

# Options
tmux_resizer_resize_count=$(tmux_get '@tmux_resizer_resize_count' '5')
tmux_resizer_vertical_resize_count=$(tmux_get '@tmux_resizer_vertical_resize_count' '5')

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

# Edit values if you use custom resize_count variables
tmux bind-key -n M-h if-shell "$is_vim" "send-keys M-h" "resize-pane -L 10"
tmux bind-key -n M-j if-shell "$is_vim" "send-keys M-j" "resize-pane -D 5"
tmux bind-key -n M-k if-shell "$is_vim" "send-keys M-k" "resize-pane -U 5"
tmux bind-key -n M-l if-shell "$is_vim" "send-keys M-l" "resize-pane -R 10"

tmux bind-key -T copy-mode-vi M-h resize-pane -L 10
tmux bind-key -T copy-mode-vi M-j resize-pane -D 5
tmux bind-key -T copy-mode-vi M-k resize-pane -U 5
tmux bind-key -T copy-mode-vi M-l resize-pane -R 10
tmux bind-key -n M-h if-shell "$is_vim" "send-keys M-h" "resize-pane -L $tmux_resizer_vertical_resize_count"
tmux bind-key -n M-j if-shell "$is_vim" "send-keys M-j" "resize-pane -D $tmux_resizer_resize_count"
tmux bind-key -n M-k if-shell "$is_vim" "send-keys M-k" "resize-pane -U $tmux_resizer_resize_count"
tmux bind-key -n M-l if-shell "$is_vim" "send-keys M-l" "resize-pane -R $tmux_resizer_vertical_resize_count"

tmux bind-key -T copy-mode-vi M-h resize-pane -L $tmux_resizer_vertical_resize_count
tmux bind-key -T copy-mode-vi M-j resize-pane -D $tmux_resizer_resize_count
tmux bind-key -T copy-mode-vi M-k resize-pane -U $tmux_resizer_resize_count
tmux bind-key -T copy-mode-vi M-l resize-pane -R $tmux_resizer_vertical_resize_count