Open Xeonacid opened 9 months ago
Note: This only affects the ZSH completion, the BASH completion is sourced automatically as one would expect.
Thanks for reporting, @Xeonacid. At the moment of writing I'm not in my computer but will test it later. That said, it looks like Zsh is not automatically sourcing that file, just stating the obvious. Which makes me think it's a Zsh issue and not Geth.
That said, it looks like Zsh is not automatically sourcing that file, just stating the obvious. Which makes me think it's a Zsh issue and not Geth.
But any other file in the same folder (/usr/share/zsh/vendor-completions
) is automatically sourced and completion works fine. I'm not a zsh expert and have no idea about what's wrong. :(
Here's a solution, demonstrated via the docker example below. This modifies /usr/share/zsh/vendor-completions/_geth
to be autoload compatible.
docker run -it --rm ubuntu:22.04 bash
apt update && apt install -y zsh software-properties-common
add-apt-repository -y ppa:ethereum/ethereum && apt install geth
cat << 'EOF' > /usr/share/zsh/vendor-completions/_geth
#compdef _geth geth
_geth() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
else
_files
fi
}
EOF
zsh
geth acc # tab --> turns into "geth account"
@Xeonacid I installed it last version and it worked fine. Can't reproduce your issue. Maybe you tried to run completion right after installing, instead of reloading your zsh and letting it sourcing the new file. Remember that the files are only sourced in the starting of the shell.
System information
Geth version: 1.13.13-stable OS & Version: Linux Ubuntu 22.04
Expected behaviour
Type
geth
then press Tab, a command completion is listed.Actual behaviour
Files in cwd is listed, acting same as without a completion.
But if run
source /usr/share/zsh/vendor-completions/_geth
manually, it works fine like a charm.Steps to reproduce the behaviour
In zsh, type
geth
then press Tab, files in cwd is listed.Other command completions in
/usr/share/zsh/vendor-completions
work fine.Run
source /usr/share/zsh/vendor-completions/_geth
and try again, completion works fine.cc @willianpaixao