Skip to content

Instantly share code, notes, and snippets.

@phcorp
Last active September 16, 2019 14:24
Show Gist options
  • Save phcorp/f15df37444d21bb2e83f853a0f2721e8 to your computer and use it in GitHub Desktop.
Save phcorp/f15df37444d21bb2e83f853a0f2721e8 to your computer and use it in GitHub Desktop.
terminal split function using tmux
##
# Splits a terminal vertically
#
# panes start synchronized, to desynchronize them, type:
# ctrl + b then :setw synchronize-panes
#
# usage: tsplit[ n]
# where n is an optional number
##
function tsplit() {
TSPLIT_WINDOWS=${1:-2}
COMMAND="tmux new-session \"tmux new-window \;"
for TSPLIT_WINDOW in `seq 2 $TSPLIT_WINDOWS`
do
COMMAND="$COMMAND split-window -d \;"
done
COMMAND="$COMMAND next-layout \; set-window-option synchronize-panes on\""
eval $COMMAND
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment