Skip to content

Instantly share code, notes, and snippets.

@hannestyden
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannestyden/9193150 to your computer and use it in GitHub Desktop.
Save hannestyden/9193150 to your computer and use it in GitHub Desktop.
tmush-first-window() {
session_name=$1
window_name=$2
cmd=$3
work_dir=$4
start_window=$window_name
if [[ "$work_dir" != "" ]]; then
cd "$work_dir"
fi
tmux start-server
tmux new-session -s $session_name -n $window_name -d
if [[ "$work_dir" != "" ]]; then
tmux set-option -t $session_name default-path "$work_dir" > /dev/null
fi
tmush-command "$session_name" "$window_name" "$cmd"
}
tmush-window() {
window_name=$1
cmd=$2
tmux new-window -t $session_name -n $window_name
tmush-command "$session_name" "$window_name" "$cmd"
}
tmush-pane() {
cmd=$1
tmux split-window -t $session_name:$window_name
tmush-command "$session_name" "$window_name" "$cmd"
}
tmush-layout() {
layout=$1
tmux select-layout -t $session_name:$window_name $layout > /dev/null
}
tmush-attach() {
tmux select-window -t $session_name:$start_window
tmux select-pane -t 1
tmux attach-session -t $session_name
}
tmush-command() {
session_name=$1
window_name=$2
cmd=$3
if [[ "$cmd" != "" ]]; then
tmux send-keys -t $session_name:$window_name "$cmd" C-m
fi
}
#!/usr/local/bin/zsh
source ~/dot/tmu.sh
tmush-first-window 'Project' 'edit' ' vim .' "$HOME/code/project"
tmush-pane ' RAILS_ENV=test bundle exec rake db:migrate && bundle exec guard'
tmush-pane ''
tmush-layout 'main-vertical'
tmush-window 'console' ' bundle exec rails console'
tmush-window 'server' ' bundle exec rake db:migrate && bundle exec rails server'
tmush-pane ' tail -f log/development.log'
tmush-layout 'even-horizontal'
tmush-window 'services' ' postgres -D /usr/local/var/postgres'
tmush-pane ' redis-server /usr/local/etc/redis.conf'
tmush-layout 'tiled'
tmush-attach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment