zellij-org / zellij

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

`strider` doesn't inherit `cwd` of `new-tab` #2131

Open angaz opened 1 year ago

angaz commented 1 year ago

Basic information

zellij --version: zellij 0.34.4, installed from nix package manager uname -av or ver(Windows): 5.15.89-1-MANJARO x86_64 GNU/Linux alacritty --version: alacritty 0.11.0 (8dbaa0bb)

Further information I have this setup: fish shell function which opens a project, I'm trying to convert this to work with zellij, I'm very new to zellij, so maybe I'm doing something wrong (commented out sections are to show what I had with tmux):

function __basedir
    echo "$HOME/Documents"
end

function __projects
    find (__basedir)/ -maxdepth 2 -type d -name .git | xargs dirname | xargs realpath --relative-to (__basedir)/
end

function p --argument-names PROJECT
    # if test -n "$PROJECT_ROOT"
    #   pushd "$PROJECT_ROOT"
    #   return "$status"
    # end

    if test -z "$PROJECT"
        echo "Error: No project or project root set"
        return 1
    end

    set -l project_root (__basedir)/$PROJECT/
    set -l layout "$HOME/.config/zellij/layouts/project.kdl"
    zellij action new-tab --layout "$layout" --name "$PROJECT" --cwd "$project_root"
    # if tmux has-session -t "$PROJECT" 2> /dev/null
    #   tmux attach-session -t "$PROJECT"
    # else
    #   set -l project_root (__basedir)/$PROJECT/
    #   tmux new-session -s "$PROJECT" -c "$project_root" -e "PROJECT_ROOT=$project_root"
    # end
end

complete -f -c p -a '(__projects)'

My project.kdl partially stolen from the docs:

layout {
    tab_template name="strider_tab" {
        pane size=1 borderless=true {
            plugin location="zellij:tab-bar"
        }
        pane split_direction="Vertical" {
            pane size="15%" {
                plugin location="zellij:strider"
            }
            children
        }
        pane size=2 borderless=true {
            plugin location="zellij:status-bar"
        }
    }

    strider_tab cwd="./" focus=true {
        pane
    }
}

I've tried a bunch of combinations of cwd in the layout file where ever I thought it seemed logical, but I cannot get strider to open in the cwd of the new tab. It always opens showing my home directory.

Is this intended behaviour? I would expect the layout to inherit it's cwd from the action new-tab call. Everything else works as expected. The new pane opens in the correct place.

If someone could verify if it can work the way I would like to use it, or show me what doing wrong, I would be grateful.

meicale commented 1 year ago

I find a similar problem. I cannot use the "global cwd" in layout. The pane relative directory can not use the cwd setted. It just uses the directory I run the "zellij action" command.

imsnif commented 1 year ago

Hey our plugins (and thus Strider) are still not able to do this unfortunately. As mentioned in the docs, this system is very much under construction at the moment. It's my next big thing to work on though, and this issue will likely be one of the first to get fixed. So stay tuned!

angaz commented 1 year ago

Cool. Thanks for confirming. I didn't know if I had a configuration problem or a feature not yet implemented. Thanks for all the hard work!

meicale commented 1 year ago

Hey our plugins (and thus Strider) are still not able to do this unfortunately. As mentioned in the docs, this system is very much under construction at the moment. It's my next big thing to work on though, and this issue will likely be one of the first to get fixed. So stay tuned!

Copy it!