zsh-snap icon indicating copy to clipboard operation
zsh-snap copied to clipboard

Change the way Znap stores plugin links

Open jck opened this issue 2 years ago • 3 comments

Describe the bug

while using znap source to install plugins like https://github.com/zsh-users/zsh-autosuggestions, an unnecessary file gets created in ~/.local/bin/zsh-autosuggestions.

This is a symlink to zsh-autosuggestions.plugin.zsh - which is not an executable.

Steps To Reproduce

znap uninstall zsh-users/zsh-autosuggestions
znap source zsh-users/zsh-autosuggestions
ls -l ~/.local/bin/zsh-autosuggestions

Expected behavior

~/.local/bin/zsh-autosuggestions is not created

Observed behavior

❯ znap uninstall zsh-users/zsh-autosuggestions
Removing:
~/.local/bin/zsh-autosuggestions
/home/jck/.local/share/zsh-snap/zsh-autosuggestions
zsh-autosuggestions uninstalled.
❯ ls -l ~/.local/bin/zsh-autosuggestions
ls: cannot access '/home/jck/.local/bin/zsh-autosuggestions': No such file or directory
❯ znap source zsh-users/zsh-autosuggestions
Cloning into 'zsh-autosuggestions'...
remote: Enumerating objects: 72, done.
remote: Counting objects: 100% (72/72), done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 72 (delta 9), reused 37 (delta 3), pack-reused 0
Receiving objects: 100% (72/72), 35.52 KiB | 845.00 KiB/s, done.
Resolving deltas: 100% (9/9), done.
❯ ls -l ~/.local/bin/zsh-autosuggestions
lrwxrwxrwx 1 jck jck 82 Jun  4 18:20 /home/jck/.local/bin/zsh-autosuggestions -> /home/jck/.local/share/zsh-snap/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
❯ cat ~/.local/bin/zsh-autosuggestions
source ${0:A:h}/zsh-autosuggestions.zsh

Environment:

  • OS: Archlinux
  • Terminal: kitty
  • Zsh version: 5.9
  • Repo version: * main b2365b1 Fix premature return from znap source

Additional context

jck avatar Jun 04 '22 17:06 jck

It's not a bug; it's a feature. source and . both search your path. Thus, it makes sense for source-able files to be in your path (and Znap adds ~/.local/bin to your $path). Additionally, the symlinks are a way for Znap to find plugin files faster.

If non-executable files in your $path are showing up as commands in your completions, add setopt HASH_EXECUTABLES_ONLY to your .zshrc file. I will add this to Znap, too.

If there are any additional drawbacks to having non-executable files in $path, please let me know and I will move them to another place.

marlonrichert avatar Jun 06 '22 13:06 marlonrichert

Thank you!

If there are any additional drawbacks to having non-executable files in $path, please let me know and I will move them to another place.

Some tools like pipx and marcosnils/bin install executables in ~/.local/bin. I have occasionally run into instances where this conflicts with the corresponding zsh plugin.

For example, I cannot install the https://github.com/ajeetdsouza/zoxide binary into ~/.local/bin and still use znap to install it's zsh plugin.

jck avatar Jun 20 '22 19:06 jck

Thanks for the feedback! I will move them to another location. Sourcing plugins on the command line doesn’t really make sense anyway. So, on second thought: No, they don’t need to be in $path after all.

marlonrichert avatar Jun 22 '22 05:06 marlonrichert

@jck Fixed. 🙂

PS: If you enjoy using my software, please consider sponsoring me. 💝

marlonrichert avatar Aug 17 '22 14:08 marlonrichert