tmux: add swap-pane.sh (ported from ruby)

This commit is contained in:
Henrik Lissner 2015-12-23 02:39:04 -05:00
parent 18a88353e5
commit 8ef7f3e62f
2 changed files with 32 additions and 5 deletions

View file

@ -77,11 +77,11 @@ bind h select-pane -L
bind j select-pane -D bind j select-pane -D
bind k select-pane -U bind k select-pane -U
bind l select-pane -R bind l select-pane -R
bind H run '~/.dotfiles/tmux/swap-pane.rb left' bind H run '~/.dotfiles/tmux/swap-pane.sh left'
bind J run '~/.dotfiles/tmux/swap-pane.rb down' bind J run '~/.dotfiles/tmux/swap-pane.sh down'
bind K run '~/.dotfiles/tmux/swap-pane.rb up' bind K run '~/.dotfiles/tmux/swap-pane.sh up'
bind L run '~/.dotfiles/tmux/swap-pane.rb right' bind L run '~/.dotfiles/tmux/swap-pane.sh right'
bind M run '~/.dotfiles/tmux/swap-pane.rb master' bind M run '~/.dotfiles/tmux/swap-pane.sh master'
bind o resize-pane -Z bind o resize-pane -Z
bind S choose-session bind S choose-session

27
tmux/swap-pane.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
swap() { tmux swap-pane -s"$1" -t"$2"; }
CONF=~/.tmux/lastpane
target=
case $1 in
up) target="U" ;;
down) target="D" ;;
left) target="L" ;;
right) target="R" ;;
master) target="M" ;;
*) exit 1 ;;
esac
src_pane=$(tmux display-message -p "#P")
tmux select-pane -${target}
dst_pane=$(tmux display-message -p "#P")
tmux select-pane -${src_pane}
if [[ "$target" == "M" ]]; then
dst_pane=0
fi
swap "$src_pane" "$dst_pane"
tmux select-pane -t"$dst_pane"