Contents

How to set autocomplete in Ubuntu

Contents

Mofidy bash.bashrc

1
sudo vi /etc/bash.bashrc

Find those code in the file

1
2
3
4
5
6
7
8
#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

Remove #

Like below:

1
2
3
4
5
6
7
8
#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

Source it

1
sudo source /etc/bash.bashrc

Now you can use Tab to autocomplete your command