Skip to content

Instantly share code, notes, and snippets.

@husjon
Created February 22, 2021 09:01
Show Gist options
  • Save husjon/8fed05156149df78de470e38284079c9 to your computer and use it in GitHub Desktop.
Save husjon/8fed05156149df78de470e38284079c9 to your computer and use it in GitHub Desktop.
#!/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