zellij
zellij copied to clipboard
`new-pane --cwd` doesn't use the given cwd
Basic information
zellij --version: zellij 0.38.1
stty size: 36 174
uname -av or ver(Windows): Linux ganymede 6.4.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 24 Aug 2023 00:38:14 +0000 x86_64 GNU/Linux
List of programs you interact with as, PROGRAM --version: output cropped meaningful, for example: N/A
Further information
Steps to reproduce:
zellijzellij action new-pane --cwd /home/p00f/foo
Expected behaviour:
New pane with ~/foo as the cwd
Actual behaviour:
New pane with the directory zellij was started in as the cwd.
Hi I think this is related on how the cwd argument is used in this function.
The cwd parameter is joined with the current_dir. If this join operation is not successful thencurrent_dir is returned.
I think this needs to be extended as follow:
- check if
cwdis an absolute path or a relative path - if
cwdis an absolute path then use it as path for the new Panel - if
cwdis a relative path then join it withcurrent_dir - otherwise use
current_dir(cwdis empty)
Also, this need to be modified for other functions too (like: NewTab link )
I need to correct myself. The cwd behavior is correct, but seems to be ignored when building a new panel.
I am looking into it :)
So I think I understood what is happening. This bug is coming from this else branch. Here we are not passing the cwd information at all to the Action::NewFloatingPane or to the Action::NewTiledPane.
Yes: https://github.com/zellij-org/zellij/blob/697723ddd30715e2997ad12352ea3c89ebdb7e17/zellij-utils/src/input/actions.rs#L356C
The Option<RunCommandAction> (second element in the tuple) should be a RunCommandAction with the given cwd: https://github.com/zellij-org/zellij/blob/697723ddd30715e2997ad12352ea3c89ebdb7e17/zellij-utils/assets/prost/api.action.rs#L239
instead of None
I think we need a way to cast a TerminalAction into a RunCommandAction as follow e.g. link. In the previous example the cast is done on the server-side.
I was unable to find the same conversion on the client-side.
On the server side the conversion can be done using the function get_default_shell as follow link,
Should we insert a get_default_shell function on the client-side too ?
Are there some other ways to get around this problem ?
I face a similar issue where the --cwd doesn't work.
Command:
zellij action new-tab --name "New Tab" --cwd "$PWD" -l default
This should (according to the docs) create a new tab window with the current directory, but instead it uses the directory from where zellij session was originally started.
This issue still exists in 0.41.2
cwd is not use in the else branch.
https://github.com/zellij-org/zellij/blob/v0.41.2/zellij-utils/src/input/actions.rs#L454-L466
WORKAROUND:
zellij action new-pane -c --cwd /tmp -- $SHELL