From ae4eb6b2b0d584fffb44980f8f32402fe90dd977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81mi=20Pre=CC=81vost?= Date: Thu, 20 Oct 2011 07:21:29 -0400 Subject: [PATCH] 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. --- README.md | 3 +++ lib/teamocil.rb | 2 +- lib/teamocil/layout.rb | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70ce59d..c52b74c 100644 --- a/README.md +++ b/README.md @@ -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) * `filters` (a hash of `before` and `after` commands to run for each split) * `splits` (an array of split items) +* `options` (a hash of tmux options, see `man tmux` for a list) #### Example windows: - name: my-first-window + options: + synchronize-panes: true root: ~/Projects/foo-www filters: before: diff --git a/lib/teamocil.rb b/lib/teamocil.rb index 88a3619..b8f8272 100644 --- a/lib/teamocil.rb +++ b/lib/teamocil.rb @@ -1,5 +1,5 @@ module Teamocil - VERSION = "0.1.10" + VERSION = "0.1.11" autoload :Layout, "teamocil/layout" autoload :CLI, "teamocil/cli" end diff --git a/lib/teamocil/layout.rb b/lib/teamocil/layout.rb index 61517da..eb5267d 100644 --- a/lib/teamocil/layout.rb +++ b/lib/teamocil/layout.rb @@ -23,6 +23,7 @@ module Teamocil def generate_commands # {{{ output = [] + # Support renaming of current session if @layout["session"].nil? windows = @layout["windows"] else @@ -39,7 +40,8 @@ module Teamocil output << "tmux new-window -n \"#{window["name"]}\"" 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"]["before"] ||= [] window["filters"]["after"] ||= [] @@ -71,6 +73,13 @@ module Teamocil 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 # Set the focus in the first split