How to add bash auto completion in CentOS 8 Linux

Originally published at: https://www.cyberciti.biz/faq/add-bash-auto-completion-in-centos-8-linux/

I set up a new cloud server, but my auto-completion of bash shell commands are not working. How do I enable autocomplete feature in CentOS 8 (CentOS Enterprise Linux 8)? How do I write simple bash completion code in CentOS 8?