Since there is a discussion (https://github.com/bitcoin/bitcoin/issues/17289#issuecomment-618736031) on whether it will slow down when user hit TAB key to send request to bitcoind for auto completion, what about we add those cword==1 commands in contrib/completions/bash/bitcoin-cli.bash so that it will not rely on the startup of bitcoind?
The suggested code is pasted below and tested:
# create cword==1 block to avoid the calling of bitcoind to get auto complete
commands = []
for command in options:
commands.append(command.command)
commands_str = " ".join(commands)
cword_1_block = f""" if ((cword == 1)); then
options=\"{commands_str}\"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
return 0\n fi\n\n"""
generated = cword_1_block