Closed jm33-m0 closed 1 year ago
I had to put it in /usr/share/zsh/site-functions
to make it work, but ~/zsh
is also in $fpath
, I'm really confused.
I suspect it's a permission issue as zsh refuses to load anything from my home directory unless I source
them.
The completion file needs to be called _chezmoi
. If the filename does not begin with an underscore then zsh will ignore it.
I did rename it to _chezmoi
but it didn't work. zsh
doesn't even load it when it's in my home directory.
I'm not sure if it's some selinux policy preventing zsh
to load the functions. As you can see here, if there's a COPR repo for chezmoi it would be very useful, and users get to update chezmoi easily.
~
❯ ls ~/.local/share/zsh/site-functions/_chezmoi
/home/jm33/.local/share/zsh/site-functions/_chezmoi
~
❯ echo $fpath
/usr/local/share/zsh/site-functions /usr/share/zsh/site-functions /usr/share/zsh/5.8.1/functions /home/jm33/.local/share/zsh/site-functions
~
❯ chezmoi
Completing file
bin/ kmod.log Templates/
Adding chezmoi to COPR is tracked in #1800.
completion
template function, which means that when chezmoi 2.27.0 is released you can make ~/.local/share/zsh/site-functions/_chezmoi
a template managed by chezmoi with the contents:{{- completions "zsh" -}}
zsh
doesn't even load it when it's in my home directory ... I'm not sure if it's some selinux policy preventing zsh to load the functions
Are you able to reproduce this problem on a new machine or in a docker container?
I found the reason, zsh reads functions before my fpath+=
statement.
fpath+=("$HOME/.local/share/zsh/site-functions") # here it should be
autoload -Uz compinit
# fpath+=("$HOME/.local/share/zsh/site-functions") # it was here
Basically my fpath
changes after compinit
so anything under the newly added path won't be loaded.
I used zsh -v 2>/tmp/zsh.log
to debug this issue.
Thanks for the help, Hope we will soon have a COPR for chezmoi!
Glad you found the solution, and thank you very much for sharing it here :)
What exactly are you trying to do?
I am trying to enable auto completion for zsh shell using
chezmoi completion zsh
What have you tried so far?
completion.zsh
file in~/zsh
and add~/zsh
to$fpath
chezmoi
the press TAB, nothing but filename completion pops upTried to
source
the file, no luck either.Where else have you checked for solutions?
fpath
, nothing happens with thatfpath
, literally nothing, not even_chezmoi
, meaning it didn't work at all.There is no instructions in the guides, they just tell me to generate the scripts, which I think everyone knows. The important part is how to enable it, since you don't have packages for most distros other than Arch.
Output of any commands you've tried with
--verbose
flagOutput of
chezmoi doctor
Additional context
Add any other context about the problem here.