Add support for a “root” window key
This commit is contained in:
parent
8047e2d994
commit
8823113219
@ -23,11 +23,12 @@ Teamocil is a tool used to automatically create sessions, windows and splits in
|
|||||||
name: sample-session
|
name: sample-session
|
||||||
windows:
|
windows:
|
||||||
- name: sample-window
|
- name: sample-window
|
||||||
|
root: ~/Code/sample/www
|
||||||
splits:
|
splits:
|
||||||
- cmd: cd ~/Code/sample/www
|
|
||||||
- cmd:
|
- cmd:
|
||||||
- cd ~/Code/sample/www
|
- ls -la
|
||||||
- rails s
|
- git status
|
||||||
|
- cmd: rails server --port 3000
|
||||||
width: 50
|
width: 50
|
||||||
- cmd: memcached -p 11211 -vv
|
- cmd: memcached -p 11211 -vv
|
||||||
height: 25
|
height: 25
|
||||||
|
@ -26,10 +26,11 @@ module Teamocil
|
|||||||
windows.each_with_index do |window, window_index|
|
windows.each_with_index do |window, window_index|
|
||||||
|
|
||||||
if options.include?(:here) and window_index == 0
|
if options.include?(:here) and window_index == 0
|
||||||
output << "tmux rename-window #{window["name"]}"
|
output << "tmux rename-window \"#{window["name"]}\""
|
||||||
else
|
else
|
||||||
output << "tmux new-window -n #{window["name"]}"
|
output << "tmux new-window -n \"#{window["name"]}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
window["splits"].each_with_index do |split, index|
|
window["splits"].each_with_index do |split, index|
|
||||||
unless index == 0
|
unless index == 0
|
||||||
if split.include?("width")
|
if split.include?("width")
|
||||||
@ -43,7 +44,13 @@ module Teamocil
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Support single command splits, but treat it as an array nevertheless
|
||||||
split["cmd"] = [split["cmd"]] unless split["cmd"].is_a? Array
|
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|
|
split["cmd"].each do |command|
|
||||||
output << "tmux send-keys -t #{index} \"#{command}\""
|
output << "tmux send-keys -t #{index} \"#{command}\""
|
||||||
output << "tmux send-keys -t #{index} Enter"
|
output << "tmux send-keys -t #{index} Enter"
|
||||||
|
Loading…
Reference in New Issue
Block a user