Skip to content

Instantly share code, notes, and snippets.

@flipsi
Created November 11, 2015 07:41
Show Gist options
  • Save flipsi/ad616ee43fff833c8acf to your computer and use it in GitHub Desktop.
Save flipsi/ad616ee43fff833c8acf to your computer and use it in GitHub Desktop.
Setup a tmux session (from inside another one)
#!/bin/bash
SESSION_NAME="coba"
SESSION_PATH="/Users/sflip/projects/commerzbank/coba/portal"
if (tmux has-session -t ${SESSION_NAME} 2>/dev/null);
then
echo "Session ${SESSION_NAME} exists."
else
# Create the session
tmux new-session -s ${SESSION_NAME} -c ${SESSION_PATH} -n ${SESSION_NAME} -d
# (1) fish
#tmux send-keys -t ${SESSION_NAME} 'pwd' C-m
# (2) file-manager
tmux new-window -t ${SESSION_NAME} -c ${SESSION_PATH} -n files
tmux send-keys -t ${SESSION_NAME}:2 'ranger' C-m
# (3) version-control
tmux new-window -t ${SESSION_NAME} -c ${SESSION_PATH} -n version-control
tmux send-keys -t ${SESSION_NAME}:3 'tig' C-m 's'
# Start out on the first window when we attach
tmux select-window -t ${SESSION_NAME}:3
echo "Session ${SESSION_NAME} created."
fi
tmux switch-client -t ${SESSION_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment