Last active
August 29, 2015 14:05
-
-
Save Genki-S/488b3d38cd93f88e3525 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 | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 (right|left)" | |
exit 1 | |
fi | |
current_win=$(tmux display-message -p '#I') | |
total_win_count=$(tmux display-message -p '#{session_windows}') | |
case "$1" in | |
"right") | |
tmux swap-window -s :$current_win -t :$(( $current_win + 1 )) &> /dev/null | |
if [ $? -ne 0 ]; then | |
# It's on the rightmost position | |
tmux swap-window -s :$current_win -t :1 | |
fi | |
;; | |
"left") | |
tmux swap-window -s :$current_win -t :$(( $current_win - 1 )) &> /dev/null | |
if [ $? -ne 0 ]; then | |
# It's on the leftmost position | |
tmux swap-window -s :$current_win -t :$total_win_count | |
fi | |
;; | |
*) | |
echo "Usage: $0 (right|left)" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment