Skip to content

Instantly share code, notes, and snippets.

@knmkr
Created January 3, 2013 06:09
Show Gist options
  • Save knmkr/4441196 to your computer and use it in GitHub Desktop.
Save knmkr/4441196 to your computer and use it in GitHub Desktop.
tmux / Split-window if there is only one pane, else select-pane.
#!/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