Skip to content

Commit

Permalink
rc4. New example for focusing panes. Fix bug where focus: pane would …
Browse files Browse the repository at this point in the history
…break when loading with tmux session.
  • Loading branch information
tony committed Dec 3, 2013
1 parent 1a1f1dc commit 173497c
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 93 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
75 changes: 40 additions & 35 deletions doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,8 @@ JSON
.. literalinclude:: ../examples/blank-panes.json
:language: json

Start Directory
---------------

Equivalent to ``tmux new-window -c <start-directory>``.

YAML
""""

.. literalinclude:: ../examples/start-directory.yaml
:language: yaml

JSON
""""

.. literalinclude:: ../examples/start-directory.json
:language: json

2 split panes
-------------
2 panes
-------

.. sidebar:: 2 pane

Expand All @@ -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
-------

Expand Down Expand Up @@ -174,7 +145,41 @@ JSON
.. literalinclude:: ../examples/4-pane.json
:language: json

Start Directory
---------------

Equivalent to ``tmux new-window -c <start-directory>``.

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
----------------

Expand Down
37 changes: 0 additions & 37 deletions examples/2-pane-vertical-long.json

This file was deleted.

17 changes: 0 additions & 17 deletions examples/2-pane-vertical-long.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions examples/focus-window-and-panes.json
Original file line number Diff line number Diff line change
@@ -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"
}
20 changes: 20 additions & 0 deletions examples/focus-window-and-panes.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tmuxp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

import logging

__version__ = '0.1.0rc2'
__version__ = '0.1.0rc4'
4 changes: 3 additions & 1 deletion tmuxp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tmuxp/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
2 changes: 1 addition & 1 deletion tmuxp/workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 173497c

Please sign in to comment.