Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

How to add bash auto completion in Ubuntu Linux

by Editorial Staff
November 12, 2018
in Linux
Reading Time: 3 mins read

[ad_1]

I set up a new Ubuntu Linux LXD container, but my auto-completion of bash shell commands are not working. How do I enable autocomplete feature in Ubuntu Linux 18.04 LTS? How do I write simple bash completion code in Ubuntu Linux?

Introduction: Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash can run most sh scripts without modification. bash-completion is a collection of shell functions that take advantage of the programmable completion feature of bash on Fedora Linux. This page shows how to install and enable Bash auto completion in Ubuntu Linux.

Table of Contents
How to add bash auto completion in Ubuntu Linux
How to add bash completion In Ubuntu
How to test programmable completion for Bash
How do I enable bash completion on Ubuntu and use it from the current session
Writing your first simple bash completion code
Conclusion

How to add bash auto completion in Ubuntu Linux

The procedure is as follows to add bash completion in Ubuntu:

  1. Open the terminal application
  2. Refresh package database on Ubuntu by running: sudo apt update
  3. Install bash-completion package on Ubuntu by running: sudo apt install bash-completion
  4. Log out and log in to verify that bash auto completion in Ubuntu Linux working properly

Let us see all steps in details.

How to add bash completion In Ubuntu

Bash completion is a useful tool for the automatically completing of file names, commands and more. Type the following apt command/apt-get command to install auto completion in Ubuntu Linux:
$ sudo apt update
$ sudo apt install bash-completion

Command to add bash auto completion in Ubuntu Linux

How to test programmable completion for Bash

Installer placed a shell script called /etc/profile.d/bash_completion.sh. You can view it with help of cat command:
$ cat /etc/profile.d/bash_completion.sh

Ubuntu bash_completion.sh to turn on bash smart completion
Bash shell code that turn on bash smart completion feature

How do I enable bash completion on Ubuntu and use it from the current session

The script will get call automatically from your login session or when you start a fresh shell session. For the current session use the source command to load it:
$ source /etc/profile.d/bash_completion.sh
Press the [TAB] key while typing a command to auto-complete syntax or options:
$ sudo apt i[TAB]
$ cat /etc/re[TAB]

Writing your first simple bash completion code

Say you always want to check an IP address of three domain names using the host command. So type the following at the shell prompt:
complete -W 'google.com cyberciti.biz nixcraft.com' host
Now type host and press the [TAB] key to use any one of the domain name for host command:
host [TAB]

Bash host command auto completion
host command with bash completion on my Ubuntu 18.04

Conclusion

The easiest way to install bash completion software is to use a package manager such as apt command. You installed the bash-completion package and learned how to create simple function and wrappers. For more info see this page.

[ad_2]

Related Posts

Apache, MySQL Performance

How to Optimize Apache, MySQL Performance for 1GB RAM VPS Centos/RHEL

April 7, 2024
Top 5 MySQL Performance Tuning Tips

Top 5 MySQL Performance Tuning Tips

January 25, 2023

Top Commands to Check the Running Processes in Linux

May 27, 2022

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022

How Common Signals are Used in Kubernetes Pod Management

November 20, 2021

How to Transfer Windows 10 to SSD?

April 14, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Articles

  • Biometric Banking: Why Your Face, Fingerprint, and Voice Are the New PIN
  • The Revolution in Telecommunications: How technology is changing connections
  • Understanding the Differences: BACS vs CHAPS Payment Systems Explained
  • Why CSPM Is the Unsung Hero of Enterprise Cloud Security
  • The New Face of Antivirus: Smarter, Faster, and Built for 2025 Threats
  • What are The Responsibilities of your tax preparer?
  • Best 10 Cryptocurrency Exchange Development Companies 2025

Related Posts

None found

  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

© Techolac © Copyright 2019 - 2022, All Rights Reserved.