Last active
August 29, 2015 14:07
-
-
Save andersonvom/704f703e3417b9b80755 to your computer and use it in GitHub Desktop.
Ruby script to start a new tmux session with the correct windows set up
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 ruby | |
HOME = Dir.home | |
OPENSTACK = File.join(HOME, 'development', 'openstack') | |
def openstack | |
session_name = 'openstack' | |
windows = { | |
screen: "cd #{OPENSTACK}; vagrant up && vagrant ssh", | |
vagrant: "cd #{OPENSTACK}; sleep 10 ; vagrant ssh", | |
heat: "cd #{OPENSTACK}/heat; vim", | |
irssi: "cd #{OPENSTACK}; irssi", | |
} | |
`tmux new-session -d -s #{session_name} -n bash` | |
windows.each_with_index do |win_info, win_idx| | |
tmux_idx = win_idx + 1 | |
win_name, win_cmd = win_info | |
`tmux new-window -t #{session_name}:#{tmux_idx} -n #{win_name}` | |
`tmux send-keys -t #{session_name}:#{tmux_idx} "#{win_cmd}" C-m` | |
end | |
`tmux select-window -t #{session_name}:0` | |
`tmux attach-session -t #{session_name}` | |
end | |
openstack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment