Created
February 22, 2021 09:01
-
-
Save husjon/8fed05156149df78de470e38284079c9 to your computer and use it in GitHub Desktop.
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/bash | |
swap() { | |
tmux swap-pane -s $1 -t $2 | |
tmux select-pane -t $1 | |
} | |
get_id() { | |
echo $(tmux run "echo #{pane_id}") | |
} | |
swap_vert() { | |
src_id=$(get_id) | |
tmux select-pane -U | |
dst_id=$(get_id) | |
tmux select-pane -D | |
swap "$src_id" "$dst_id" | |
} | |
swap_horz() { | |
src_id=$(get_id) | |
tmux select-pane -R | |
dst_id=$(get_id) | |
tmux select-pane -L | |
swap $src_id $dst_id | |
} | |
case "$1" in | |
up|down) | |
swap_vert | |
;; | |
left|right) | |
swap_horz | |
;; | |
*) | |
echo "Usage:" | |
echo "$(basename $0) <up|down|left|right>" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment