Skip to content

Commit

Permalink
Add support for a “root” window key
Browse files Browse the repository at this point in the history
  • Loading branch information
remi committed Jul 20, 2011
1 parent 8047e2d commit 8823113
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ Teamocil is a tool used to automatically create sessions, windows and splits in
name: sample-session
windows:
- name: sample-window
root: ~/Code/sample/www
splits:
- cmd: cd ~/Code/sample/www
- cmd:
- cd ~/Code/sample/www
- rails s
- ls -la
- git status
- cmd: rails server --port 3000
width: 50
- cmd: memcached -p 11211 -vv
height: 25
Expand Down
11 changes: 9 additions & 2 deletions lib/teamocil/layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def generate_commands # {{{
windows.each_with_index do |window, window_index|

if options.include?(:here) and window_index == 0
output << "tmux rename-window #{window["name"]}"
output << "tmux rename-window \"#{window["name"]}\""
else
output << "tmux new-window -n #{window["name"]}"
output << "tmux new-window -n \"#{window["name"]}\""
end

window["splits"].each_with_index do |split, index|
unless index == 0
if split.include?("width")
Expand All @@ -43,7 +44,13 @@ def generate_commands # {{{
end
end

# Support single command splits, but treat it as an array nevertheless
split["cmd"] = [split["cmd"]] unless split["cmd"].is_a? Array

# If a `root` key exist, start each split in this directory
split["cmd"] = ["cd \"#{window["root"]}\""] + split["cmd"] if window.include?("root")

# Execute each split command
split["cmd"].each do |command|
output << "tmux send-keys -t #{index} \"#{command}\""
output << "tmux send-keys -t #{index} Enter"
Expand Down

0 comments on commit 8823113

Please sign in to comment.