Created
January 3, 2013 06:09
-
-
Save knmkr/4441196 to your computer and use it in GitHub Desktop.
tmux / Split-window if there is only one pane, else select-pane.
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/sh | |
## Split-window if there is only one pane, else select-pane. | |
## | |
## Set key-binding to run this script, in .tmux.conf, like, | |
## bind -n C-t run "/path/to/tmux-split-or-select-pane.sh" | |
# check if more than one pane exists | |
tmux list-panes > /tmp/tmux.list-panes | |
awk '{if ($1!="0:") {exit 1}}' /tmp/tmux.list-panes | |
status=$? | |
# if exists -> select, else -> split | |
if [ ${status} == 1 ]; then | |
tmux select-pane -R | |
else | |
tmux split-window -h | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment