Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Viroide opened this issue Sep 1, 2023 · 5 comments
Open

Comments

@Viroide
Copy link

Viroide commented Sep 1, 2023

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
@matzxrr
Copy link

matzxrr commented Feb 5, 2024

This looks like the same issue...

#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/"

@radumotrescu
Copy link

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.

@TheRustifyer
Copy link

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

@optimizasean
Copy link

optimizasean commented Apr 15, 2024

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
Copy link

@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.

aboqasem added a commit to aboqasem/dotfiles that referenced this issue May 25, 2024
aboqasem added a commit to aboqasem/dotfiles that referenced this issue May 26, 2024
Workaround `layout_dir` not being dynamic by specifying
ZELLIJ_CONFIG_DIR, default layouts path will be under
$ZELLIJ_CONFIG_DIR/layouts, see:
- https://github.com/zellij-org/zellij/blob/c72f3a712bfa92a4a80b4c1ad1dbe7669892a324/docs/MANPAGE.md#files
- zellij-org/zellij#2764
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants