tmux: add swap-pane.sh (ported from ruby)
This commit is contained in:
parent
18a88353e5
commit
8ef7f3e62f
10
tmux.conf
10
tmux.conf
|
@ -77,11 +77,11 @@ bind h select-pane -L
|
|||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
bind H run '~/.dotfiles/tmux/swap-pane.rb left'
|
||||
bind J run '~/.dotfiles/tmux/swap-pane.rb down'
|
||||
bind K run '~/.dotfiles/tmux/swap-pane.rb up'
|
||||
bind L run '~/.dotfiles/tmux/swap-pane.rb right'
|
||||
bind M run '~/.dotfiles/tmux/swap-pane.rb master'
|
||||
bind H run '~/.dotfiles/tmux/swap-pane.sh left'
|
||||
bind J run '~/.dotfiles/tmux/swap-pane.sh down'
|
||||
bind K run '~/.dotfiles/tmux/swap-pane.sh up'
|
||||
bind L run '~/.dotfiles/tmux/swap-pane.sh right'
|
||||
bind M run '~/.dotfiles/tmux/swap-pane.sh master'
|
||||
|
||||
bind o resize-pane -Z
|
||||
bind S choose-session
|
||||
|
|
27
tmux/swap-pane.sh
Executable file
27
tmux/swap-pane.sh
Executable 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"
|
Loading…
Reference in a new issue