File tree 3 files changed +113
-0
lines changed
3 files changed +113
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,41 @@ newer and tmux 3.0 or newer.
287
287
288
288
````
289
289
290
+ ## ` if ` conditions
291
+
292
+ tmuxp enables one to optionally open windows / panes based on coditions. The ` if ` conditions can appears in the configuration for window or pane.
293
+
294
+ ```` {tab} YAML
295
+
296
+ ```{literalinclude} ../../examples/if-conditions.yaml
297
+ :language: yaml
298
+
299
+ ```
300
+ ````
301
+
302
+ ```` {tab} JSON
303
+
304
+ ```{literalinclude} ../../examples/if-conditions.json
305
+ :language: json
306
+
307
+ ```
308
+
309
+ ````
310
+
311
+ In the example, running the example
312
+
313
+ ``` console
314
+ $ tmuxp load examples/if-conditions.yaml
315
+ ```
316
+
317
+ should produce ** only** a window with upper and lower split panes (others should have ` if ` conditions that evaluates to false). This example allows for on-demand pane showing, where
318
+
319
+ ``` console
320
+ $ show_htop=false tmuxp load examples/if-conditions.yaml
321
+ ```
322
+
323
+ will insteads suppress the ` htop ` command pane and resulting in a different behaviour.
324
+
290
325
## Focusing
291
326
292
327
tmuxp allows ` focus: true ` for assuring windows and panes are attached /
Original file line number Diff line number Diff line change
1
+ {
2
+ "session_name" : " if conditions test" ,
3
+ "environment" : {
4
+ "Foo" : " false" ,
5
+ "show_htop" : " true"
6
+ },
7
+ "windows" : [
8
+ {
9
+ "window_name" : " window 1 ${ha} $Foo" ,
10
+ "if" : {
11
+ "shell" : " ${Foo}"
12
+ },
13
+ "panes" : [
14
+ {
15
+ "shell_command" : [
16
+ " echo \" this shouldn't shows up\" "
17
+ ]
18
+ },
19
+ " echo neither should this $Foo"
20
+ ]
21
+ },
22
+ {
23
+ "window_name" : " window 2" ,
24
+ "panes" : [
25
+ {
26
+ "if" : {
27
+ "python" : " 1+1==3"
28
+ },
29
+ "shell_command" : [
30
+ " echo the above is a false statement"
31
+ ]
32
+ },
33
+ {
34
+ "shell_command" : [
35
+ " echo no condition" ,
36
+ " python -m http.server"
37
+ ]
38
+ },
39
+ {
40
+ "if" : " ${show_htop}" ,
41
+ "shell_command" : [
42
+ " echo the above is a true statement (by default), but can be disabled on-demand" ,
43
+ " htop"
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ ]
49
+ }
Original file line number Diff line number Diff line change
1
+ session_name : if conditions test
2
+ environment :
3
+ Foo : ' false'
4
+ show_htop : ' true'
5
+ windows :
6
+ # the following would not shows up as it evaluates to false
7
+ - window_name : window 1 ${ha} $Foo
8
+ if :
9
+ shell : ${Foo}
10
+ panes :
11
+ - shell_command :
12
+ - echo "this shouldn't shows up"
13
+ - echo neither should this $Foo
14
+ - window_name : window 2
15
+ panes :
16
+ # should not shows up
17
+ - if :
18
+ python : 1+1==3
19
+ shell_command :
20
+ - echo the above is a false statement
21
+ # no if conditions
22
+ - shell_command :
23
+ - echo no condition
24
+ - python -m http.server
25
+ # display by default, but can be disabled by running `show_htop=false tmuxp load .....`
26
+ - if : ${show_htop}
27
+ shell_command :
28
+ - echo the above is a true statement (by default), but can be disabled on-demand
29
+ - htop
You can’t perform that action at this time.
0 commit comments