Skip to content

Instantly share code, notes, and snippets.

@AliKhadivi
Created September 19, 2021 04:30
Show Gist options
  • Save AliKhadivi/22dd64be26559f0ae255f26648f4615d to your computer and use it in GitHub Desktop.
Save AliKhadivi/22dd64be26559f0ae255f26648f4615d to your computer and use it in GitHub Desktop.
Enable bash autocomplate! before run ( sudo apt-get install --reinstall bash-completion )
# enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
@AliKhadivi
Copy link
Author

bash-completion is a set of bash scripts which enables customized completion for specific commands.

This is not just for files and directories, but also e.g. for the commands. So you type partial of commands and by hitting Tab we get a auto completion of commands.

Installation

Step 1: Install bash-completion

$ sudo apt-get install bash-completion

And some times it works if we re-installed it by the follwing command:

$ sudo apt-get install --reinstall bash-completion

Step 2: Enable bash-completion in your .bashrc file

Open your vim ~/.bashrc and if these content doesn't exist there, add them at the end of it and save it.

    # enable bash completion in interactive shells
    if ! shopt -oq posix; then
      if [ -f /usr/share/bash-completion/bash_completion ]; then
        . /usr/share/bash-completion/bash_completion
      elif [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
      fi
    fi

Important: After changing the file you need to source your ~/.bashrc with source ~/.bashrc or reopen your Terminal. It should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment