Skip to content

Commit 6baf949

Browse files
committed
New shorthand example. Allow shorter pane commands
1 parent 6a89d2d commit 6baf949

File tree

5 files changed

+76
-3
lines changed

5 files changed

+76
-3
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ See: `Quickstart`_
3535
CLI Commands
3636
""""""""""""
3737

38+
==========================
39+
40+
``tmuxp attach-session``
41+
``tmuxp kill-session``
42+
``tmuxp convert``
43+
``tmuxp import``
44+
``tmuxp import``
45+
3846
tmuxp uses ``switch-client`` for you if already in a TMUX client.
3947

4048
.. code-block:: bash

doc/examples.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,35 @@
44
Examples
55
========
66

7+
Short hand / inline
8+
-------------------
9+
10+
.. sidebar:: short hand
11+
12+
.. aafig::
13+
14+
+-----------------+
15+
| $ |
16+
| |
17+
+-----------------+
18+
| $ |
19+
| |
20+
+-----------------+
21+
| $ |
22+
+-----------------+
23+
24+
YAML
25+
""""
26+
27+
.. literalinclude:: ../examples/shorthands.yaml
28+
:language: yaml
29+
30+
JSON
31+
""""
32+
33+
.. literalinclude:: ../examples/shorthands.json
34+
:language: json
35+
736
2 split panes
837
-------------
938

examples/shorthands.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"windows": [
3+
{
4+
"panes": [
5+
{
6+
"shell_command": [
7+
"echo 'did you know'",
8+
"echo 'you can inline'"
9+
]
10+
},
11+
{
12+
"shell_command": "echo 'single commands'"
13+
},
14+
"echo 'for panes'"
15+
],
16+
"window_name": "long form"
17+
}
18+
],
19+
"session_name": "shorthands"
20+
}

examples/shorthands.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
session_name: shorthands
2+
windows:
3+
- window_name: long form
4+
panes:
5+
- shell_command:
6+
- echo 'did you know'
7+
- echo 'you can inline'
8+
- shell_command: echo 'single commands'
9+
- echo 'for panes'

tmuxp/config.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,16 @@ def expand(config):
155155

156156
# recurse into window and pane config items
157157
if 'windows' in config:
158-
config['windows'] = [expand(window)
159-
for window in config['windows']]
160-
if 'panes' in config:
158+
config['windows'] = [
159+
expand(window) for window in config['windows']
160+
]
161+
elif 'panes' in config:
162+
for p in config['panes']:
163+
if isinstance(p, basestring):
164+
p_index = config['panes'].index(p)
165+
config['panes'][p_index] = {
166+
'shell_command': [p]
167+
}
161168
config['panes'] = [expand(pane) for pane in config['panes']]
162169

163170
return config

0 commit comments

Comments
 (0)