diff --git a/CHANGES b/CHANGES index e8c428089b2..b4c45fb51b6 100644 --- a/CHANGES +++ b/CHANGES @@ -4,12 +4,19 @@ Changelog Here you can find the recent changes to tmuxp. +0.1-rc4 +------- + +- [bug] fix bug were ``focus: true`` would not launch sessions when using + ``$ tmuxp load`` in a tmux session. + 0.1-rc3 ------- - [bug] [tests] `Issue #25`_ - ``focus: true`` not working in panes. Add tests for focusing panes in config. - [internal] :meth:`Pane.select_pane()`. +- [docs] add new example for ``focus: true``. .. _Issue #25: https://github.com/tony/tmuxp/issues/25 diff --git a/doc/examples.rst b/doc/examples.rst index 932c2176d04..84abcad193f 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -58,25 +58,8 @@ JSON .. literalinclude:: ../examples/blank-panes.json :language: json -Start Directory ---------------- - -Equivalent to ``tmux new-window -c ``. - -YAML -"""" - -.. literalinclude:: ../examples/start-directory.yaml - :language: yaml - -JSON -"""" - -.. literalinclude:: ../examples/start-directory.json - :language: json - -2 split panes -------------- +2 panes +------- .. sidebar:: 2 pane @@ -92,30 +75,18 @@ JSON | | +-----------------+ -YAML - Short form -""""""""""""""""" +YAML +"""" .. literalinclude:: ../examples/2-pane-vertical.yaml :language: yaml -JSON - Short form -""""""""""""""""" +JSON +"""" .. literalinclude:: ../examples/2-pane-vertical.json :language: json -YAML - Christmas Tree -""""""""""""""""""""" - -.. literalinclude:: ../examples/2-pane-vertical-long.yaml - :language: yaml - -JSON - Christmas Tree -""""""""""""""""""""" - -.. literalinclude:: ../examples/2-pane-vertical-long.json - :language: json - 3 panes ------- @@ -174,7 +145,41 @@ JSON .. literalinclude:: ../examples/4-pane.json :language: json +Start Directory +--------------- + +Equivalent to ``tmux new-window -c ``. + +YAML +"""" +.. literalinclude:: ../examples/start-directory.yaml + :language: yaml + +JSON +"""" + +.. literalinclude:: ../examples/start-directory.json + :language: json + +Focusing +-------- + +tmuxp allows ``focus: true`` for assuring windows and panes are attached / +selected upon loading. + +YAML +"""" + +.. literalinclude:: ../examples/focus-window-and-panes.yaml + :language: yaml + +JSON +"""" + +.. literalinclude:: ../examples/focus-window-and-panes.json + :language: json + Automatic Rename ---------------- diff --git a/examples/2-pane-vertical-long.json b/examples/2-pane-vertical-long.json deleted file mode 100644 index 887664403da..00000000000 --- a/examples/2-pane-vertical-long.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "windows": [ - { - "panes": [ - { - "shell_command": [ - "cd ~", - "pwd", - "top" - ] - }, - { - "shell_command": [ - "cd /var/www", - "pwd" - ] - } - ], - "window_name": "test" - }, - { - "panes": [ - { - "shell_command": "pwd" - }, - { - "shell_command": [ - "pwd" - ] - } - ], - "shell_command_before": "cd /var/www", - "window_name": "second window" - } - ], - "session_name": "2-pane-vertical-long" -} \ No newline at end of file diff --git a/examples/2-pane-vertical-long.yaml b/examples/2-pane-vertical-long.yaml deleted file mode 100644 index f1003a54255..00000000000 --- a/examples/2-pane-vertical-long.yaml +++ /dev/null @@ -1,17 +0,0 @@ -session_name: 2-pane-vertical-long -windows: - - window_name: test - panes: - - shell_command: - - cd ~ - - pwd - - top - - shell_command: - - cd /var/www - - pwd - - window_name: second window - shell_command_before: cd /var/www - panes: - - shell_command: pwd - - shell_command: - - pwd diff --git a/examples/focus-window-and-panes.json b/examples/focus-window-and-panes.json new file mode 100644 index 00000000000..3448b8ac9f9 --- /dev/null +++ b/examples/focus-window-and-panes.json @@ -0,0 +1,38 @@ +{ + "windows": [ + { + "panes": [ + { + "shell_command": [ + "pwd", + "echo 'this pane should be selected on load'" + ], + "focus": true + }, + { + "shell_command": [ + "cd /var/log", + "pwd" + ] + } + ], + "window_name": "attached window on load", + "focus": true + }, + { + "panes": [ + "pane", + { + "shell_command": [ + "echo 'this pane should be focused, when window switched to first time'" + ], + "focus": true + }, + "pane" + ], + "shell_command_before": "cd /var/www", + "window_name": "second window" + } + ], + "session_name": "focus window and pane when loading sessions" +} \ No newline at end of file diff --git a/examples/focus-window-and-panes.yaml b/examples/focus-window-and-panes.yaml new file mode 100644 index 00000000000..9db5ac8c2b1 --- /dev/null +++ b/examples/focus-window-and-panes.yaml @@ -0,0 +1,20 @@ +session_name: focus +windows: + - window_name: attached window + focus: true + panes: + - shell_command: + - pwd + - echo 'this pane should be selected on load' + focus: true + - shell_command: + - cd /var/log + - pwd + - window_name: second window + shell_command_before: cd /var/log + panes: + - pane + - shell_command: + - echo 'this pane should be focused, when window switched to first time' + focus: true + - pane diff --git a/tmuxp/__init__.py b/tmuxp/__init__.py index 09604b1a207..8bce3537089 100644 --- a/tmuxp/__init__.py +++ b/tmuxp/__init__.py @@ -21,4 +21,4 @@ import logging -__version__ = '0.1.0rc2' +__version__ = '0.1.0rc4' diff --git a/tmuxp/util.py b/tmuxp/util.py index a47ea5822d0..6451c654fc7 100644 --- a/tmuxp/util.py +++ b/tmuxp/util.py @@ -188,7 +188,9 @@ def by(val, *args): return list(filter(by, self.children)) def getById(self, id): - """Return object based on `.get()`_ from `backbone.js`_. + """Return object based on ``childIdAttribute``. + + Based on `.get()`_ from `backbone.js`_. .. _backbone.js: http://backbonejs.org/ .. _.get(): http://backbonejs.org/#Collection-get diff --git a/tmuxp/window.py b/tmuxp/window.py index c65cd757936..4d2e3cf315b 100644 --- a/tmuxp/window.py +++ b/tmuxp/window.py @@ -295,7 +295,8 @@ def select_window(self): :rtype: :class:`Window` """ - return self.session.select_window(self.get('window_id')) + target = '%s:%s' % (self.get('session_id'), self.get('window_index')), + return self.session.select_window(target) def select_pane(self, target_pane): """Return selected :class:`Pane` through ``$ tmux select-pane``. diff --git a/tmuxp/workspacebuilder.py b/tmuxp/workspacebuilder.py index 4303e66a245..d8523b47f10 100644 --- a/tmuxp/workspacebuilder.py +++ b/tmuxp/workspacebuilder.py @@ -196,7 +196,7 @@ def iter_create_windows(self, s): w.set_window_option(key, val) if 'focus' in wconf and wconf['focus']: - s.select_window(w['window_id']) + w.select_window() s.server._update_windows()