Skip to content
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

Environment variables inside cwd #2288

Closed
shahamran opened this issue Mar 14, 2023 · 1 comment · Fixed by #2291
Closed

Environment variables inside cwd #2288

shahamran opened this issue Mar 14, 2023 · 1 comment · Fixed by #2291

Comments

@shahamran
Copy link
Contributor

Hi, and thank you for this amazing project!

I'm trying to define a layout which I'll share with my teammates, and it includes paths that contain env variables that may be different between users. For example, I want to do something like:

layout {
  pane name="profiling" cwd="/somewhere/$USER/profiling"
}

where $USER is such environment variable.
When I open zellij with such layout, it silently falls back to current dir.

I actually consider the current behavior a bug. IMO it should either fail with an error, or do the right thing. (I realize that "the right thing" here is complicated because of cwd composition.)
Adding a section on "what happens if a path is invalid", and "what paths are valid" to the creating-a-layout doc page will also be helpful.

Thanks again!

shahamran added a commit to shahamran/zellij that referenced this issue Mar 15, 2023
* add `shellexpand` as dependency
* expand environment variable in kdl parser's `parse_cwd()`
@shahamran
Copy link
Contributor Author

I created a PR that adds support for this.

Also, I take back what I said about this being a bug. It's clearly marked as an error in the log file. I guess it can be more clear where the log file is located.

imsnif pushed a commit that referenced this issue Apr 28, 2023
* feat(layout): Support environment variables in cwd (#2288)

* add `shellexpand` as dependency
* expand environment variable in kdl parser's `parse_cwd()`

* Fix and enhance environment variable expansion.

* Return a proper `ConfigError` on failures.
* Replace raw cwd parsing with `parse_cwd()`.
* Add tests that verify correct expansions.

* Perform env var expansion in more contexts.

* feat(layout): Rewrite env var tests as snapshots.

* Update layout env var expansion test snapshot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant