Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

shell-设置tab自动补全

ubuntu

  • 修改启动文件

    sudo vim /etc/bash.bashrc
    
  • 找到下面内容,去掉里面的注释

    #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
    
  • 重载启动文件

    sudo source /etc/bash.bashrc
    
    • 这里可能会失败,说source命令没找到
      • 需要先执行sudo -s切换到root状态,才能执行
      • 执行完后,exit退出root状态即可