Skip to content

Instantly share code, notes, and snippets.

@gentunian
Created March 17, 2020 19:41
Show Gist options
  • Save gentunian/09d7fee83104fe00828f68a285b91164 to your computer and use it in GitHub Desktop.
Save gentunian/09d7fee83104fe00828f68a285b91164 to your computer and use it in GitHub Desktop.
tmux code golf
#!/bin/sh
splitHorizontal() { tmux split-window -d -t 0 -h ; }
splitVertical() { tmux split-window -d -t $1 -v ; }
replicateM() { for i in `seq 1 $1`; do splitHorizontal; done }
splitEven() { for i in `seq 0 $1`; do splitVertical $(($i * 2)); done }
die() { echo $1 && exit 1; }
#[[ $1 -lt 1 || $1 -gt 3 ]] && die "Number of nodes needs to be between 1 and 3."
tmux new-session -d -s luke ;
tmux select-layout event-horizontal
replicateM $(($1 - 1))
splitEven $(($1 - 1))
tmux attach-session -d -t luke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment