Centos/Mac 命令自动补全

2019-08-30 2728点热度 1条评论

常常使用tab来补全需要的命令参数,但在最小化安装系统的时候默认不安装,由于软件在epel库中,安装时先安装epel-release,再安装bash-completion,且需要重新建立bash环境。

Centos
yum -y install epel-release yum -y install bash-completion # or Debian apt-get install bash-completion -y
Mac
brew install bash-completion # 写入设置,具体的可以通过 brew info bash-completion 查看 vim ~/.zshrc fpath=(/usr/local/share/zsh-completions $fpath) plugins=(... zsh-completions) autoload -U compinit && compinit

Docker

curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh

# 激活,在.bashrc中添加如下配置

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
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

Jalena

原创内容,转载请注明出处! 部分内容来自网络,请遵守法律适用!

文章评论

  • repostone

    非技术的路过。

    2019-08-30