Skip to content

Instantly share code, notes, and snippets.

@haolian9
Created June 12, 2021 14:49
Show Gist options
  • Save haolian9/6fd9e92d1e33c77bf01125c9feb84c1e to your computer and use it in GitHub Desktop.
Save haolian9/6fd9e92d1e33c77bf01125c9feb84c1e to your computer and use it in GitHub Desktop.
interactive tmux resize-pane
# resize pane
# take a look at `-i` option of command-prompt
bind R command-prompt -i -p 'resize-pane' 'run-shell "~/.scripts/:resize %%"'
#!/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