快速开始
安装zsh
centos8系统:
shell
sudo dnf update -y
sudo dnf install zsh -y修改用户默认shell:
shell
chsh -s $(which zsh)安装Oh-My-Zsh
执行以下命令安装:
shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"关闭自动更新
修改~/.zshrc文件,添加以下内容到开头:
shell
export DISABLE_AUTO_UPDATE="true"或者执行命令一键添加:
bash
sed -i '/# Path to your Oh My Zsh installation/i export DISABLE_AUTO_UPDATE="true"' ~/.zshrc如需手动更新,执行:omz update。
自定义主题
执行以下命令:
shell
echo 'PROMPT="[%{$fg_bold[green]%}✗ %{$fg[cyan]%}%~%{$reset_color%}]%{$fg[yellow]%}➜ %{$reset_color%}"' \
>~/.oh-my-zsh/custom/themes/maqian.zsh-theme
sed -i 's#ZSH_THEME="robbyrussell"#ZSH_THEME="maqian"#' ~/.zshrc或者手动修改~/.oh-my-zsh/custom/themes/maqian.zsh-theme填入以下内容:
ini
PROMPT="[%{$fg_bold[green]%}✗ %{$fg[cyan]%}%~%{$reset_color%}]%{$fg[yellow]%}➜ %{$reset_color%}"替换主题:
shell
sed -i 's#ZSH_THEME="robbyrussell"#ZSH_THEME="maqian"#' ~/.zshrc自定义插件
一键命令
执行命令:
bash
mkdir -p ~/.oh-my-zsh/custom/plugins/maqian/ && echo '# docker
alias dpl="docker pull"
# git
alias gpl="git pull"
alias gps="git push"
# go
alias gmt="go mod tidy"' | tee ~/.oh-my-zsh/custom/plugins/maqian/maqian.plugin.zsh
sed -i 's/plugins=(\([^)]*\))/plugins=(\1 maqian)/' ~/.zshrc手动执行
执行:
shell
mkdir ~/.oh-my-zsh/custom/plugins/maqian/ -p
touch ~/.oh-my-zsh/custom/plugins/maqian/maqian.plugin.zsh使用vi打开~/.oh-my-zsh/custom/plugins/maqian/maqian.plugin.zsh更新内容:
shell
# docker
alias dpl='docker pull'
# git
alias gpl='git pull'
alias gps='git push'
# go
alias gmt='go mod tidy'更新插件:
bash
sed -i 's/plugins=(\([^)]*\))/plugins=(\1 maqian)/' ~/.zshrc第三方插件
Docker插件
bash
sed -i 's/plugins=(\([^)]*\))/plugins=(\1 docker kubectl)/' ~/.zshrc