Having enjoyed the command auto-completion in the Debug Console of the GUI wallet, how can I have that luxury in a command-line (CLI) only environment?
(This article was inspired by CaveSpectre's pull-request #762.) https://github.com/Veil-Project/veil/pull/762 )


Recent Ubuntu versions come with bash-completion already installed, but you can ensure that it is installed by the following: 

sudo apt update
sudo apt install bash-completion

It will tell you it is already installed if it already is.


You can also verify that it is installed by viewing the script that it will have added: 

cat /etc/profile.d/bash_completion.sh


IF NECESSARY you can add this script to your login profile (~/.bashrc or ~/.bash_profile) by adding these lines to that file: 

## source it from ~/.bashrc or ~/.bash_profile ##
echo "source /etc/profile.d/bash_completion.sh" >> ~/.bashrc
## Another example Check and load it from ~/.bashrc or ~/.bash_profile ##
grep -wq '^source /etc/profile.d/bash_completion.sh' ~/.bashrc || echo 'source /etc/profile.d/bash_completion.sh'>>~/.bashrc

like this: 

nano ~/.bashrc

Don't add that if the following already works!



From Veil's Github source code, in
veil/contrib/veil-cli.bash-completion and
veil/contrib/veild.bash-completion create a new text file for each
(in /usr/share/bash-completion/completions) respectively, simply named veil-cli and veild.
Copy and paste the contents of the bash-completion files into those new files on your Linux computer.

nano /usr/share/bash-completion/completions/veil-cli

Use Ctrl+O and Ctrl+X to save and exit. (Or use your own preferred text editor.)

nano /usr/share/bash-completion/completions/veil-cli

nano /usr/share/bash-completion/completions/veild


Alternatively you may copy the files from the Veil source code and just rename them in the target folder, removing the file extension. Also do this to add bash completion for veil-tx if you use that. I never do, so I don't need to.


For working on files owned by root, like this, use your preferred method (sudo or su root) to get edit rights.
I'm not explaining this for five year olds, because five years olds should not be playing around with root access.
You can search the Internet for learning resources.


You may need to activate the bash-completion without logging out and in again, by typing (or copy and pasting): 

source /etc/profile.d/bash_completion.sh



Test the above by typing something like this in your usual Veil binaries folder: 

./v⟹-c⟹getbal⟹s

(where ⟹ is the Tab key on your keyboard) resulting in 

./veil-cli getbalances


See also that 

./v⟹-c⟹li⟹t⟹

results in

./veil-cli listtransactions 

after which you may optionally add further parameters, such as  "*" 100 .