zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
21.43k stars 650 forks source link

Environment variables are not recognised in config files #2574

Open MurtadhaInit opened 1 year ago

MurtadhaInit commented 1 year ago

Basic information

zellij --version: zellij 0.37.1 stty size: 24 150 uname -av or ver(Windows): Darwin macbookpro.local 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 arm64

List of programs you interact with as, PROGRAM --version: wezterm 20230408-112425-69ae8472

Further information In short, having envrionment variables as values for configuration settings in config.kdl is problematic. E.g. having this line: default_shell $SHELL Results in the following error message when opening zellij:

image

And using quotes around it like so: default_shell "$SHELL" Results in zellij running but with the prompt hanging like this:

image

You can't do much here except quit zellij.

Those issues don't occur when I set an absolute path like so: default_shell "/opt/homebrew/bin/zsh"

The same thing happens for other options. For instance: scrollback_editor "/opt/homebrew/bin/nvim" This works. But this: scrollback_editor $EDITOR does not work. Even though the value of that env variable is set in zsh rc files to command -v nvim

This seems inconsistent with the documentation that mentions the default values for those options are as I typed above. If I'm missing something or some notation that I should have used, please let me know.

jaeheonji commented 1 year ago

Hi, @MurtadhaInit

By default, zellij's config file does not support environments. (such as $SHELL, $EDITOR)

// Choose the path to the default shell that zellij will use for opening new panes // Default: $SHELL // // default_shell "fish"

A comment in the config file means that if you don't set a specific shell, it will act as the default shell. That doesn't mean it supports $SHELL env.

And the PR of #2291 only contains the code to support env for layout files. Therefore, in order to apply this feature to the config file, we need to update the zellij-utils/src/kdl/mod.rs

MurtadhaInit commented 1 year ago

Thanks for the clarification @jaeheonji 🙂 I didn't know that was the case.

steakhutzeee commented 6 months ago

Hi, this change would have a great impact. Particularly for those who version control their dotfiles. Any chance there is an update about it?

Thanks!