Last active
October 19, 2016 19:13
-
-
Save FernandoBasso/70c6c94232af41edfc216add7f6a19e1 to your computer and use it in GitHub Desktop.
Just to start tmux with some tabs ready to start coding in a certain directory/project.
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 bash | |
usage() { | |
printf "\nUsage: ${0##*/} path session\n\n" | |
printf " path: a path like \`~/projs/foo\`\n" | |
printf " session: a name for the session tmux will create\n" | |
} | |
if (($# < 2)); then | |
usage | |
exit 1 | |
fi | |
dir="$1" | |
ses="$2" | |
if [[ ! -d "$dir" ]] ; then | |
printf >&2 "Directory \`%s\` not found.\n" "$dir" | |
printf >&2 "The project “%s” doesn't seem to be on this machine.\n" "$ses" | |
printf >&2 "Bailing out..." | |
exit 1 | |
fi | |
# NOTE: base-index is set to 1 (relevant for the window numbers in commands). | |
tmux new-session -d -s "$ses" -c "$dir" \; rename-window 'vim' \; \ | |
send-keys vim C-m | |
# php -S takes a host name, without the protocol:// part. | |
tmux new-window -t "${ses}:2" -n emacs -c "$dir" \; \ | |
send-keys 'emacs -nw' C-m | |
tmux new-window -t "${ses}:3" -n ssh -c "$dir" | |
tmux new-window -t "${ses}:4" -n git -c "$dir" \; \ | |
send-keys 'git status' C-m | |
tmux new-window -t "${ses}:5" -n shell -c "$dir" | |
tmux select-window -t "${ses}:1" | |
tmux -2 attach-session -t "$ses" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment