xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.43k stars 180 forks source link

Incorrect macOS zsh/site-functions Directory to Install Completions #311

Open lace-wing opened 3 months ago

lace-wing commented 3 months ago

Description

With nb completions install --download, nb tries to install zsh completions into /usr/share/zsh/site-functions/. This should work, except on macOS, that folder is protected by the system and not even sudo can grant user/group write permission to it.

nb completions install -d outputs as follows

! Exists: /opt/homebrew/Cellar/bash-completion@2/2.12.0/share/bash-completion/completions/nb
! Exists: /opt/homebrew/Cellar/fish/3.7.0/share/fish/vendor_completions.d/nb.fish
! Permission denied: /usr/share/zsh/site-functions

Repro

Run sudo nb completions install -d on a version of macOS, which zsh has been its default shell and homebrew has been installed.

Solution

One could use their own zsh/site-functions/ directory.

For instance, brew give it to /opt/homebrew/share/zsh/site-functions/. nb should install zsh completion scripts to such location. Other zsh completions there has been working well.

Alternatives

Since completions for other 2 shells has been installed to their correct brew directories, I believe the Solution is viable and there's no better/simpler approach.