Add support for options in a window item

For example, you could synchronize all commands sent to a window by
adding this in your window item:

    options:
      synchronize-panes: true

See the `set-window-option` section of the tmux manual (`man tmux`) for
a list of all the options you can use.
This commit is contained in:
Rémi Prévost 2011-10-20 07:21:29 -04:00
parent 331ab490ce
commit ae4eb6b2b0
3 changed files with 14 additions and 2 deletions

View File

@ -45,11 +45,14 @@ If you are not using a top-level `session` key, then the first key of your layou
* `root` (the directory in which every split will be created) * `root` (the directory in which every split will be created)
* `filters` (a hash of `before` and `after` commands to run for each split) * `filters` (a hash of `before` and `after` commands to run for each split)
* `splits` (an array of split items) * `splits` (an array of split items)
* `options` (a hash of tmux options, see `man tmux` for a list)
#### Example #### Example
windows: windows:
- name: my-first-window - name: my-first-window
options:
synchronize-panes: true
root: ~/Projects/foo-www root: ~/Projects/foo-www
filters: filters:
before: before:

View File

@ -1,5 +1,5 @@
module Teamocil module Teamocil
VERSION = "0.1.10" VERSION = "0.1.11"
autoload :Layout, "teamocil/layout" autoload :Layout, "teamocil/layout"
autoload :CLI, "teamocil/cli" autoload :CLI, "teamocil/cli"
end end

View File

@ -23,6 +23,7 @@ module Teamocil
def generate_commands # {{{ def generate_commands # {{{
output = [] output = []
# Support renaming of current session
if @layout["session"].nil? if @layout["session"].nil?
windows = @layout["windows"] windows = @layout["windows"]
else else
@ -39,7 +40,8 @@ module Teamocil
output << "tmux new-window -n \"#{window["name"]}\"" output << "tmux new-window -n \"#{window["name"]}\""
end end
# Make sure we have a `filters` key and it contains arrays # Make sure we have all the keys we need
window["options"] ||= {}
window["filters"] ||= {} window["filters"] ||= {}
window["filters"]["before"] ||= [] window["filters"]["before"] ||= []
window["filters"]["after"] ||= [] window["filters"]["after"] ||= []
@ -71,6 +73,13 @@ module Teamocil
end end
end end
# Set tmux options
window["options"].each_pair do |option, value|
value = "on" if value === true
value = "off" if value === false
output << "tmux set-window-option #{option} #{value}"
end
end end
# Set the focus in the first split # Set the focus in the first split