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

zsh completions: fixed issue with some arguments having invalid syntax #1216

Merged
merged 1 commit into from
Feb 19, 2024
Merged

zsh completions: fixed issue with some arguments having invalid syntax #1216

merged 1 commit into from
Feb 19, 2024

Conversation

fredricocalamari
Copy link
Contributor

Fixed issue where the completions were showing invalid syntax ex. '--additional-flags' and a few others were being incorrectly completed as '--additional-flags='

@89luca89
Copy link
Owner

Thanks a lot @fredricocalamari !

Seeing that you're a zsh user, can I ask you if you can help with the installation path of zsh autocompletion? Regarding #1213

@fredricocalamari
Copy link
Contributor Author

fredricocalamari commented Feb 19, 2024

Thanks a lot @fredricocalamari !

Seeing that you're a zsh user, can I ask you if you can help with the installation path of zsh autocompletion? Regarding #1213

Zsh completions are put in

/usr/share/zsh/site-functions

*I recommended placing them in a different function folder earlier, and that works too, but @onurmercury is also correct and site-functions is easier.

or a custom directory like

~/.local/zsh/completions

distrobox should go in the /usr/share/zsh/site-functions folder or If you want, you can store zsh completion files in a custom directory. This is what I do:
I create directories

mkdir -p ~/.local/zsh/completions

Then I chmod 644 the completion files and then I symlink or copy them into that directory. Do not organize them into subdirectories. Just put them all in one folder. After that, open ~/.zshrc and add this towards the top. It doesn't have to be at the very top, just above most everything else and among a common section with setting/exporting of environmental variables:

fpath=(~/.local/zsh/completions/ $fpath)
autoload -Uz compinit && compinit
for func in $^fpath/*(N-.x:t); do
    autoload $func
done

I don't think the last 3 lines are strictly necessary. I'ts probably just ocd. Anyways, restart zsh and type distrobox<space><tab> and the zsh compinit system should show a complete list of arguments with descriptions below. The zsh completion system is incredibly advanced (and MUCH more complicated to code for) than Bash and you can continue combining and completing subcommands with dashes to see what other arguments apply to the compound command.

@fredricocalamari
Copy link
Contributor Author

fredricocalamari commented Feb 19, 2024

@89luca89
Copy link
Owner

Thanks everyone for the info!

And thanks @fredricocalamari for the fixes!

@89luca89 89luca89 merged commit 00c19cb into 89luca89:main Feb 19, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants