Created
June 12, 2021 14:49
-
-
Save haolian9/6fd9e92d1e33c77bf01125c9feb84c1e to your computer and use it in GitHub Desktop.
interactive tmux resize-pane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# resize pane | |
# take a look at `-i` option of command-prompt | |
bind R command-prompt -i -p 'resize-pane' 'run-shell "~/.scripts/:resize %%"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
interactive() { | |
while read -r -s -n 1 op; do | |
case $op in | |
h) | |
tmux resize-pane -L 10 | |
;; | |
j) | |
tmux resize-pane -D 5 | |
;; | |
k) | |
tmux resize-pane -U 5 | |
;; | |
l) | |
tmux resize-pane -R 10 | |
;; | |
q|$'\e') | |
break | |
;; | |
*) | |
>&2 echo "unsupported $op" | |
;; | |
esac | |
done | |
} | |
oneshot() { | |
# support `tmux command-prompt -i` | |
case "$1" in | |
*h) | |
tmux resize-pane -L 10 | |
;; | |
*j) | |
tmux resize-pane -D 5 | |
;; | |
*k) | |
tmux resize-pane -U 5 | |
;; | |
*l) | |
tmux resize-pane -R 10 | |
;; | |
*=|*) | |
;; | |
esac | |
} | |
case "$1" in | |
-i) | |
interactive | |
;; | |
*) | |
oneshot "$@" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment