------------------------------------------------------------------------------- Bash Completion TO get a list of the current completion function calls... complete -p Tutorials https://debian-administration.org/article/316/An_introduction_to_bash_completion_part_1 COMP_WORDS array containing all individual words in the current command line. COMP_CWORD index of the word containing the current cursor position. COMPREPLY output array from which Bash reads the possible completions. # reduce the list of words that could be completed compgen -W "list of words to select from" -- "${cur} The Standard installation comes from https://github.com/scop/bash-completion/blob/master/bash_completion Completion scripts are placed in /usr/share/bash-completion/completions As per the command: pkg-config --variable=completionsdir bash-completion These are loaded automatically only when needed. OR in user personal directory ~/.local/share/bash-completion which is set by $BASH_COMPLETION_USER_DIR, or $XDG_DATA_HOME/bash-completion Files in the old backward compatibility directory: /etc/bash_completion.d are pre-loaded! As pre command: pkg-config --variable=compatdir bash-completion ------------------------------------------------------------------------------- Basic Example of implementing BASH Completion. Based on... https://askubuntu.com/questions/68175/#483149 Example Script you want completion for... script [-options] cmd1|cmd2|cmd3 script --help-list-options # list defined options script --help-list-commands # list defined commands =======8<--------CUT HERE----------axes/crowbars permitted--------------- _script() { COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" # the word being completed prev="${COMP_WORDS[COMP_CWORD-1]}" # the previous word (option) opts="--help --verbose --version" _script_options=$(script --help-list-options) _script_commands=$(script --help-list-commands) if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${_script_options}" -- ${cur}) ) return 0 fi COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) ) return 0 } complete -o nospace -F _script admin.sh =======8<--------CUT HERE----------axes/crowbars permitted--------------- Lots more complete examples in /etc/bash_completion.d/ of course. If the command only has simple words... complete can do the job directly complete -W "cmd1 cmd2 cmd3" admin.sh -------------------------------------------------------------------------------