Last active
February 26, 2017 11:23
-
-
Save liorrozen/94dc3a23dbafbcf32942 to your computer and use it in GitHub Desktop.
Tmux scripting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SESSION=sess_name | |
PROJ_FOLDER=proj_name | |
cd $PROJ_FOLDER | |
# if the session is already running, attach to it. | |
tmux has-session -t $SESSION | |
if [ $? -eq 0 ]; then | |
echo "Session $SESSION already exists. Attaching." | |
tmux -2 attach -t $SESSION | |
exit 0; | |
fi | |
tmux start-server | |
# create a new session, named $SESSION, and detach from it | |
tmux -2 new-session -d -s $SESSION | |
tmux set-option -g allow-rename off | |
tmux new-window -t $SESSION:1 -n "vim" | |
tmux new-window -t $SESSION:2 | |
tmux new-window -t $SESSION:3 -n "server" | |
tmux send-keys -t $SESSION:1 "vim -c 'set tags=~/$SESSION-tags'" Enter | |
tmux send-keys -t $SESSION:3 'kill "$(< tmp/pids/server.pid)"' Enter | |
tmux send-keys -t $SESSION:3 "rails s" Enter | |
# start with vim window | |
tmux select-window -t $SESSION:1 | |
tmux -2 attach -t $SESSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment