zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Layouts cannot be found when using `$HOME` or `~` in the setting`layout_dir`.

Open Viroide opened this issue 1 year ago • 5 comments

Layouts cannot be found when using $HOME or ~ in the settinglayout_dir.

Changing to an absolute path works fine.

Basic information

zellij --version: zellij 0.38.0 stty size: 59 237 uname -av: Darwin Jons-Mac-Studio.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64

Further information

From zellij setup --check:

...
[LAYOUT DIR]: "~/dotfiles/zellij/layouts/"
...

The folder contains layouts:

~ ❯ ls ~/dotfiles/zellij/layouts/                                          
default.kdl       demo.kdl          rails_desktop.kdl rails_laptop.kdl

But when trying to load a layout without full path I get:

~ ❯ zellij -l demo.kdl                                                     
IoError: No such file or directory (os error 2), File: demo.kdl
~ ❯ zellij -l demo                                                         
IoError: The layout was not found, File: demo

Viroide avatar Sep 01 '23 11:09 Viroide

This looks like the same issue...

https://github.com/zellij-org/zellij/issues/3102

From what I can see, the zellij setup --check command will just dump the string found for layout_dir if its defined, but it doesn't check if its "valid" path.

Rust &Path and PathBuf don't natively interpolate environment variables like $HOME. And things like ~/path/to/folder don't work either because tilda is a shell feature that just exapnds to the home directory.

It would be nice to support $HOME so users can configure custom relative directories.


Not sure if the maintainers intend to support this. I would be happy to open an MR to it.

Do you want to allow expansion for every env variable or just a list of ones that have been allowed like $HOME

Someone might want to do something like this...

layout_dir "$HOME/.config/${VM_NAME}_layout/"

matzxrr avatar Feb 05 '24 08:02 matzxrr

I've been having the same inconvenience, if you want to use stow or any similar tool for multiple machines, you can't use the same path for all machines. The messy solution is to make an alias for zellij --layout /absolute/path and make that specific for each machine.

radumotrescu avatar Feb 16 '24 10:02 radumotrescu

I've been having the same inconvenience, if you want to use stow or any similar tool for multiple machines, you can't use the same path for all machines. The messy solution is to make an alias for zellij --layout /absolute/path and make that specific for each machine.

Even for dotfiles. I want to setup up to four different machines with Zellij, but I can't, since I have no unified user names

TheRustifyer avatar Apr 06 '24 17:04 TheRustifyer

The $HOME expansion would definitely be nice as well as other shell environment variables being made available.

As an easier and quicker to implement alternative for people - following convention: default theme and layout directories should be ~/.config/zellij/layouts and ~/.config/zellij/themes that way we can easily drop into those folders. It appears to be that way on my system (at least for layouts is true on my system - just do not edit the variable and leave commented out and this should be default).

EDIT: You can symlink individual files into there, haven't tested folders as I don't want to mess things up too much. The .config is also user specific so it should be easy to copy without username specification although for layouts you can expand from $HOME so assuming you structure things the same on each PC it should work.

Otherwise default working directory when opening a zellij layout is current directory of your terminal so just cd and then open your layout and no need to specify paths for basic things like opening editors.

optimizasean avatar Apr 15 '24 22:04 optimizasean

@radumotrescu @TheRustifyer - does zellij not follow symlinks? It appears to work on my system - symlinking layout_name.kdl to .config/zellij/layouts/.

Potentially hacky but if you made a symlink from ~/.config/zellij to your dotfile or config folder/repo then it might work if you have it laid out the same? That is how I was managing most of my dotfiles for a while, now I just rsync .config at the moment. stow certainly looks like a more elegant solution but I am not familiar with it.

As an alternative I plan to try out later once I have time, checkout Rotz which is a dotfile manager written in rust. If that fails me I might just do an rsync git repo on a flash drive and a bash install script to either ln or cp if symlinks fail from folder to $USER for everything.

optimizasean avatar Apr 15 '24 22:04 optimizasean