Skip to content

Instantly share code, notes, and snippets.

@l-x
Created February 19, 2016 09:59
Show Gist options
  • Save l-x/8f90894ab6d0a593f874 to your computer and use it in GitHub Desktop.
Save l-x/8f90894ab6d0a593f874 to your computer and use it in GitHub Desktop.
#!/bin/sh
CONF_DIR="$HOME/.cmux"
LAYOUT=tiled
CMD_FILE="$1"
SESSION_NAME=$(basename "$CMD_FILE")
if ! [ -e "$CMD_FILE" ]; then
CMD_FILE="$CONF_DIR/$CMD_FILE"
if ! [ -e "$CMD_FILE" ]; then
echo "Command file '$1' not found"
exit 88
fi
fi
FIRST_CMD=1
while read CMD; do
if [ "$FIRST_CMD" == 1 ]; then
if ! [ -z "$TMUX" ]; then
tmux new-window -n "$SESSION_NAME" "$CMD"
else
tmux -2 new-session -d -s "$SESSION_NAME" -n "$SESSION_NAME" "$CMD"
fi
FIRST_CMD=0
else
tmux split-window -h -d "$CMD"
tmux select-layout $LAYOUT
fi
done < $CMD_FILE
tmux set-window-option -t $SESSION_NAME synchronize-panes
if [ -z "$TMUX" ]; then
tmux -2 attach-session -t $SESSION_NAME
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment