berberman / nvfetcher

Generate nix sources expr for the latest version of packages
https://nvfetcher.torus.icu
MIT License
168 stars 14 forks source link

[feature] Shell completion #98

Closed Freed-Wu closed 7 months ago

Freed-Wu commented 1 year ago

Can nvfetch provide completions for common shells? nvfetch -<TAB> will complete options. TIA!

berberman commented 7 months ago

Completion scripts are already included. You may need to tell your shell to load those files if nvfetcher is not installed globally on your system.

$ tree result
result
├── bin
│   └── nvfetcher
└── share
    ├── bash-completion
    │   └── completions
    │       └── nvfetcher
    ├── fish
    │   └── vendor_completions.d
    │       └── nvfetcher.fish
    └── zsh
        └── vendor-completions
            └── _nvfetcher

9 directories, 4 files
Freed-Wu commented 7 months ago

zsh shell completion should be in share/zsh/site-functions.

berberman commented 7 months ago

IIUC zsh looks for directories in fpath.

$ print -l $fpath | grep vendor-completions
/home/berberman/.nix-profile/share/zsh/vendor-completions
/nix/profile/share/zsh/vendor-completions
/home/berberman/.local/state/nix/profile/share/zsh/vendor-completions
/etc/profiles/per-user/berberman/share/zsh/vendor-completions
/nix/var/nix/profiles/default/share/zsh/vendor-completions
/run/current-system/sw/share/zsh/vendor-completions
Freed-Wu commented 7 months ago

Oh, I found it. Seem more developers like site-functions. It should not be a big problem.

❯ eza --icons --git -h /run/current-system/sw/share/zsh/site-functions|wc -l
239
❯ eza --icons --git -h /run/current-system/sw/share/zsh/vendor-completions
 _cachix   _dpkg-parsechangelog   _nvfetcher