You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

If you keep getting an error message “_get_comp_words_by_ref: command not found” when you try bash completion for custom command with completion script, it means the bash-completion package is not installed. Tab completion feature is used to automatically complete commands or suggest options when you press Tab.

Fix _get_comp_words_by_ref: command not found

A fix for “_get_comp_words_by_ref: command not found” is to install bash-completion package. The commands to run varies from one Linux distribution to another, depending on the package management tool you use.

Install bash-completion on CentOS / RHEL:

sudo yum -y install bash-completion

Install bash-completion on Fedora:

sudo dnf -y install bash-completion

Install bash-completion on Ubuntu / Debian

sudo apt install bash-completion

Install bash-completion on macOS:

brew install bash-completion

After installing bash-completion on your system. Logout of current session:

$ logout

Login back and source your completion script.

$ source /path/to/completion/script

If source command has been added to ~/.bashrc file, then just run:

$ source ~/.bashrc

Now try using tab completion. See example below.

$ oc  <TAB>
adm              cancel-build     delete           extract          logout           plugin           replace          serviceaccounts  
annotate         cluster-info     describe         get              logs             policy           rollback         set              
api-resources    completion       diff             idle             new-app          port-forward     rollout          start-build      
api-versions     config           edit             image            new-build        process          rsh              status           
apply            convert          ex               import-image     new-project      project          rsync            tag              
attach           cp               exec             kustomize        observe          projects         run              version          
auth             create           explain          label            options          proxy            scale            wait             
autoscale        debug            expose           login            patch            registry         secrets          whoami       

I hope this guide helped you to fix “_get_comp_words_by_ref: command not found” error on your Linux / macOS terminal.

How To Copy and Paste Text Content from Linux Terminal

Connect To VPN Server with Cisco AnyConnect from Linux Terminal

How To Connect To Bluetooth Device from Linux Terminal

How To Google Search from a Linux Terminal

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF