[LINUX] [Personal memo] Auto-completion of bash


Longer Linux commands can be tedious and inefficient So, I'll leave the procedure for setting auto-completion of commands.

Introduction method

  1. Install bash-completion

    > yum install -y bash-completion
  2. Load & Confirm

    > source /usr/share/bash-completion/bash_completion
    #OK if there are no errors
    > type _init_completion
  3. As an example, input completion setting of yum command

    > source /usr/share/bash-completion/completions/yum
    #After inputting yum, if the input completion is displayed with the tab key as shown below, it is OK
    > yum 
      check  deplist  groups  info  load-transaction  reinstall  search  upgrade
      check-update   distro-sync   help   install  makecache   remove   shell  version
      clean   downgrade   history    list   provides     repolist   update 
  1. What if it's not in / usr / share / bash-completion / completions /? Some things are built into the command. For example, in the case of kubectl, kubectl completion bash provides the completion function. In the case of docker-compose, install the auto-completion script according to this procedure and load it in the same way. So please find the one you want to complement and load it.

  2. Automatic load registration

 > echo 'source /usr/share/bash-completion/bash_completion' >> ~/.bashrc
 > echo 'source /usr/share/bash-completion/yum' >> ~/.bashrc

When _get_comp_words_by_ref command not found is displayed

Try the following two

bash_completion is not loaded

Execute "2. Load & Confirm" above

bash_completion is not installed

Install bash-completion from your package manager

Execute "1. Install bash-completion" above

Recommended Posts

[Personal memo] Auto-completion of bash
Confirmation of impulse response (personal memo)
[OpenCV] Personal memo
Bash script memo
The pain of gRPC using Python. November 2019. (Personal memo)
Handling of quotes in [bash]
Qiita memo of my thoughts
Features of programming languages [Memo]
[Memo] Construction of cygwin environment
Variable parameter expansion of bash
How to use cron (personal memo)
[Python] Operation memo of pandas DataFrame
Judgment of holidays including holidays with bash
Linux Frequently Used Commands [Personal Memo]
[Personal memo] Python virtual environment command memo
Easy usage memo of Anaconda (conda)
Environment construction memo of pyenv + conda
Python3 compatible memo of "python start book"
[Memo] Small story of pandas, numpy
Understanding memo of collective intelligence programming
[Personal memo] Python sequence type / mapping type
find / grep command (beginner's personal memo)
Separate display of Python graphs (memo)
Operation memo of Conda virtual environment
Linux command (basic in basic) personal memo