Created
May 21, 2014 18:43
-
-
Save aymanfarhat/fa1d9a4a42a4ba29df87 to your computer and use it in GitHub Desktop.
Start a project and its common windows with tmux
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
#!/bin/sh | |
if [ -z "$1" ] ; then | |
echo "usage: $0 <projectname> [/path/to/project]" | |
exit 1 | |
fi | |
MYPROJECT=$1 | |
if [ -z "$2" ] ; then | |
ROOT=${MYPROJECT} | |
else | |
ROOT=$2 | |
fi | |
echo ${ROOT} | |
# Bootstrap a new session called ${MYPROJECT} | |
tmux new-session -d -s ${MYPROJECT} | |
# Name the windows | |
tmux rename-window -t ${MYPROJECT}:0 "servers" | |
tmux new-window -t ${MYPROJECT}:1 -n "vim" | |
tmux new-window -t ${MYPROJECT}:2 -n "bash" | |
# "C-m" emulates an enter | |
# On window 0, move to the directory with the source code | |
tmux send-keys -t ${MYPROJECT}:0 "cd ${ROOT}" C-m | |
# Split window 0 to two and navigate to project dir | |
tmux split-window -h -t ${MYPROJECT}:0 | |
tmux send-keys -t ${MYPROJECT}:0 "cd ${ROOT}" C-m | |
# On window 2 also move to directory with source code | |
tmux send-keys -t ${MYPROJECT}:2 "cd ${ROOT}" C-m | |
# Move to the directory with the source code and start Vim | |
tmux send-keys -t ${MYPROJECT}:1.1 "cd ${ROOT}" C-m | |
tmux send-keys -t ${MYPROJECT}:1.0 "cd ${ROOT}" C-m | |
tmux send-keys -t ${MYPROJECT}:1.0 "vim" C-m | |
# Switch to window 1 | |
tmux select-window -t ${MYPROJECT}:1 | |
# Force tmux to assume the terminal supports 256 colors and attach to the | |
# target session "${MYPROJECT}" | |
tmux -2 attach-session -t ${MYPROJECT} |
Exactly that's what I do :D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!
I've managed to paste it into
/usr/local/bin/yalla
then make it executable withchmod +x /usr/local/bin/yalla
so now I canyalla wle ~/hon
👍