Mac系统配置k8s completion命令补全
k8s学习
·
查看当前bash版本
/bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
Copyright (C) 2007 Free Software Foundation, Inc.
- bash3.2版本无法进行命令补全,具体查看官网描述macos配置bash补全功能
升级bash
- 命令:
brew install bash
- 查看当前系统bash
which -a bash
/usr/local/bin/bash # 新安装bash
/bin/bash # 旧bash
- 查看新bash版本
/usr/local/bin/bash --version
GNU bash,版本 5.1.16(1)-release (x86_64-apple-darwin20.6.0)
Copyright (C) 2020 Free Software Foundation, Inc.
设置默认bash
- 执行
sudo vim /etc/shells
将新的/usr/local/bin/bash
加到最后一行
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/bash
- 将bash切到最新版本
chsh -s /usr/local/bin/bash
Changing shell for zsx.
Password for zsx:
安装 bash-completion
- 执行命令:
brew install bash-completion@2
- 将命令输出显示内容添加到
~/.bash_profile
中
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
- 导入source kuberctl的补全脚本
echo 'source <(kubectl completion bash)' >>~/.bash_profile
验证补全功能
- 重启shell
- 重试kuberctl补全功能
更多推荐
已为社区贡献2条内容
所有评论(0)