Created
May 31, 2015 19:44
-
-
Save ewilazarus/f78c3d59e420fd3a531a to your computer and use it in GitHub Desktop.
Script created to bootstrap tmux session for python development
This file contains hidden or 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
#!/usr/bin/env sh | |
TARGET_DIR=~/Workspace | |
PY_VERSION=python3 | |
while getopts d:p:v: opts; do | |
case ${opts} in | |
d) TARGET_DIR=${OPTARG} ;; | |
p) PY_VERSION=${OPTARG} ;; | |
v) VENV=${OPTARG} ;; | |
esac | |
done | |
# Creates new session 'devenv' with a window called 'vim' | |
tmux new-session -s devenv -n run -d | |
tmux send-keys -R -t devenv:0 "cd ${TARGET_DIR}" C-m C-l | |
if [ ! -z "$VENV" ] | |
then | |
tmux send-keys -R -t devenv:0 "workon ${VENV}" C-m C-l | |
fi | |
# Creates new window called 'vim' | |
tmux new-window -t devenv -n vim | |
# Makes the 'vim' window title fixed | |
tmux set-window-option -tdevenv:1 -g allow-rename off | |
# CD into the given directory | |
tmux send-keys -R -t devenv:1 "cd ${TARGET_DIR}" C-m C-l | |
if [ ! -z "$VENV" ] | |
then | |
tmux send-keys -R -t devenv:1 "workon ${VENV}" C-m C-l | |
fi | |
tmux send-keys -R -t devenv:1 'vim' C-m | |
tmux send-keys -R -t devenv:1 C-n | |
# Creates new window called 'shell/repl' | |
tmux new-window -t devenv -n shell/repl | |
# Makes the 'shell/repl' window title fixed | |
tmux set-window-option -t devenv:2 -g allow-rename off | |
# Splits the 'shell/repl' window vertically | |
tmux split-window -t devenv:2 -h | |
tmux send-keys -R -t devenv:2.0 "cd ${TARGET_DIR}" C-m C-l | |
tmux send-keys -R -t devenv:2.0 'ls' C-m | |
tmux send-keys -R -t devenv:2.1 "cd ${TARGET_DIR}" C-m C-l | |
if [ ! -z "$VENV" ] | |
then | |
tmux send-keys -R -t devenv:2.1 "workon ${VENV}" C-m C-l | |
fi | |
tmux send-keys -R -t devenv:2.1 "${PY_VERSION}" C-m | |
# Set focus to the pane 2.0 (shell) | |
tmux select-pane -t devenv:2.0 | |
# Selects the 'vim' window | |
tmux select-window -t devenv:1 | |
# Attaches to the session | |
tmux attach -t devenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment