-
Notifications
You must be signed in to change notification settings - Fork 233
Implements if conditions for pane and window
#942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice documentation, example, well annotated!
Allowed CI to run.
-
Rebase to get the latest updates
-
Adding a test would make it 5-stars (example:
EXAMPLE_PATHw/blank-panes.yamlintest_builder.py::test_blank_pane_spawn) -
ruff checkhas some complaints (job)You may get automated fixes from something like
ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes --ignore T201 --ignore F401 --ignore PT014 --ignore RUF100; ruff format ..(While I actually prefer your styling better than what ruff would do above, I use
ruffto enforce consistency at scale)
Signed-off-by: Tin Lai <tin@tinyiu.com>
Signed-off-by: Tin Lai <tin@tinyiu.com>
Signed-off-by: Tin Lai <tin@tinyiu.com>
Signed-off-by: Tin Lai <tin@tinyiu.com>
1b2fff5 to
5b27974
Compare
Signed-off-by: Tin Lai <tin@tinyiu.com>
Signed-off-by: Tin Lai <tin@tinyiu.com>
|
I've expanded the approach, where [ 5 -gt 1 ]or echo ${MY_ENV} | grep fooThe
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewinding a bit, it this safe?
Can you think of any other software projects that have declarative configurations directly execute code? 1
I suppose:
- CI: Jenkins, CircleCI, GitHub actions
- Container software: Docker (perhaps the CI systems could be considered a subset of that)
- Configuration managers: Ansible, Salt
- Shell script: Run commands like bashrc, zshrc
- Vim: Vim configuration
Add second qualifier on top of that: when the code is also executed in an if expression.
Is eval() or subprocess.run(..., shell=True) too permissive for an if?
I can't tell yet. I would like to see more examples from other projects to see their best practices.
Alternative approach?
Could you make a second PR with a more limited if that avoid eval / subprocess passthroughs?
operator expressions
One way, it could have something wrapping operator:
if:
- a: ${SHELL}
op: eq
b: 'bash'Where a and b could be replaced by envionmental variables via os.path.expandvars() and op could accept a method of operator.
Separate script
To make the conditional more explicit, they can be separate shell scripts and run though a subprocess.Popen, similar to run_before_script(), but they're explicit commands and piped through libtmux.
Anything else?
Anything that could make if flexible, yet constrained?
Footnotes
-
The
shell_commandsin tmuxp configurations are typed into a pty / tmux pane, to be fair. ↩
|
Yes I also partially agree that the use of However, the more I think about it, the more I reckon that the nature of From my point of view,
RE:
Aside from the examples that you have given (many of which just execute any commands given without any security measure), my experience with
|
Closes #741
This implements both
shellandpythonconditions.ifcan be a:shellkey)pythonorshellkey.A
pythonkey will be evaluated as a python expression, and will test for its pythonic truthfulnessA
shellkey will test as a shell variable and any of the following will be evaluated to true:("y", "yes", "1", "on", "true", "t")(case-insensitivity)In the example, by default,
show_htop=true, but since it's a shell variable, it can be override by user. Hence, use can on-deamnd customise their pane/window configuration byand
which will have different behaviour, for different use-cases