oh-my-zsh的Github仓库地址:https://github.com/ohmyzsh/ohmyzsh
安装zsh
oh-my-zsh安装之前必须要先将shell环境切换成zsh
https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
for centos
1 2
| sudo yum update && sudo yum -y install zsh && \ chsh -s $(which zsh)
|
for debian
1 2
| sudo apt install -y zsh && \ chsh -s $(which zsh)
|
安装 on-my-zsh
1
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
或者
1
| sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
国内安装特别慢,建议使用魔法
插件安装
一键安装脚本:
第五行中是针对第一次安装oh-my-zsh的的内容做文本替换,如果不是第一次安装会替换失败,需要自己手动维护plugins和ZSH_THEME
1 2 3 4 5 6
| git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && \ git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && \ git clone --depth=1 https://github.com/paulirish/git-open.git $ZSH_CUSTOM/plugins/git-open && \ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k && \ [ -f ~/.zshrc ] && { grep -q '^plugins=(git)$' ~/.zshrc && sed -i '' 's/^plugins=(git)$/plugins=(git zsh-autosuggestions extract zsh-syntax-highlighting)/' ~/.zshrc || echo "⚠️ 未找到 plugins=(git),未进行替换。"; grep -q '^ZSH_THEME="robbyrussell"$' ~/.zshrc && sed -i '' 's/^ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc || echo "⚠️ 未找到 ZSH_THEME=\"robbyrussell\",未进行替换。"; echo "✅ 操作完成,如未生效请重新打开终端或执行 source ~/.zshrc"; } || echo "❌ 文件 ~/.zshrc 不存在,无法进行修改。" && \ source ~/.zshrc
|
zsh-autosuggestions
介绍: 可以根据历史记录提供提示命令
github地址: https://github.com/zsh-users/zsh-autosuggestions
安装教程: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md
1
| git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
1
| plugins=(zsh-autosuggestions)
|
介绍: 一键解压,不用再去记tar各种命令
github地址: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/extract
不需要安装直接在plugins中增加extract即可
zsh-syntax-highlighting
介绍: 命令高亮提示
github地址: https://github.com/zsh-users/zsh-syntax-highlighting
1
| git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
1
| plugins=( [plugins...] zsh-syntax-highlighting)
|
git-open
介绍:直接在终端界面打开对应仓库的页面信息
1
| git clone --depth=1 https://github.com/paulirish/git-open.git $ZSH_CUSTOM/plugins/git-open
|
主题
powerlevel10k/powerlevel10k
github地址: https://github.com/romkatv/powerlevel10k
1
| git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
|
然后修改.zshrc
1
| ZSH_THEME="powerlevel10k/powerlevel10k"
|