zellij-org / zellij

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

`$HOME` is expanded differently depending on command #3417

Open cschmatzler opened 2 weeks ago

cschmatzler commented 2 weeks ago

Initially reported as https://github.com/dj95/zjstatus/issues/65

2. Issues with the Zellij UI / behavior / crash

Issue description

When adding a plugin with file:$HOME/..., the $HOME variable is correctly expanded when opening Zellij, but fails when running actions such as zellij action new-tab -l zjstatus -c ~/Development.

Minimal reproduction

layouts/zjstatus.kdl:

layout {
    pane split_direction="vertical" {
        children
    }
    pane size=1 borderless=true {
        plugin location="file:$HOME/.config/zellij/plugins/zjstatus.wasm" {
            format_left   "{mode} #[fg=#1e66f5,bold]{session}"
            format_center "{tabs}"
            format_right  "{datetime}"
            format_space  ""

            border_enabled  "false"
            border_char     "─"
            border_format   "#[fg=#6C7086]{char}"
            border_position "top"

            hide_frame_for_single_pane "true"

            mode_locked "#[fg=#dce0e8,bg=#e64553,bold] LOCKED "
            mode_normal "#[fg=#dce0e8,bg=#1e66f5,bold] NORMAL "
            mode_resize "#[fg=#dce0e8,bg=#179299,bold] RESIZE "
            mode_pane   "#[fg=#dce0e8,bg=#ea76cb,bold] PANE "
            mode_tab    "#[fg=#dce0e8,bg=#8839ef,bold] TAB "

            tab_normal   "#[fg=#1e66f5] {name} "
            tab_active   "#[fg=#8839ef,bold] {name} "

            datetime        "#[fg=#6C7086,bold] {format} "
            datetime_format "%A, %d %b %Y %H:%M"
            datetime_timezone "Europe/Berlin"
        }
    }
}

This works when opening a new zellij session, but results in the following when running it as zellij action new-tab -l zjstatus -c ~/Development: image image (thanks @dj95 for investigating and the second screenshot! ❤️ )

Other relevant information

This gets resolved by replacing $HOME with ~ or an absolute path, but I'd still consider it a bug.