Linux安装Oh-my-zsh
一、安装
1.1、安装zsh
yum install zsh
1.2、安装git
yum install git
1.3、下载oh-my-zsh
的安装脚本
- 安装wget(centos7默认是没有的)
yum install wget
1.4、下载 zsh 安装脚本
- 我这里因为用 github 源无法下载,一直卡在 clone into "xxx",所以改换了国内的镜像源
# gitee 源
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
1.5、编辑 install.sh
找到以下部分
# Default settings
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
把
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
替换为
REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
1.6、编辑后保存, 运行安装即可. (运行前先给install.sh权限)
# 赋予可执行权限
chmod +x install.sh
# 运行
sh install.sh
1.7、修改仓库地址
cd ~/.oh-my-zsh
git remote set-url origin https://gitee.com/mirrors/oh-my-zsh.git
git pull
二、切换为 zsh
2.1、输入cat /etc/shells
命令来查看本地安装的shell
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh
/bin/zsh
2.2、切换sehll至zsh
chsh -s /bin/zsh
2.3、查看当前使用的shell
echo $SHELL
三、oh-my-zsh插件设置
3.1、编辑主题和插件
vim ~/.zshrc
- 修改主题:找到下面设置主题的部分,修改引号中的名称即可(比如我这里用的
ysagnoster 主题)
#ZSH_THEME="ys"
ZSH_THEME="agnoster"
- 修改插件:找到插件的部分,直接修改,常用的插件可以自行参考网上其他文章
plugins=(git
sublime
z
web-search
wd
zsh-autosuggestions
extract
zsh-syntax-highlighting)
3.2、安装字体
agnoster
主题需要Meslo
字体,否则会乱码或不正常显示。
点击下载Meslo LG M Regular for Powerline.ttf字体:https://github.com/powerline/fonts/tree/master/Meslo Slashed/Meslo LG M Regular for Powerline.ttf
。
安装完成后,将终端字体设置为Meslo LG M Regular for Powerline
即可。
3.3、刷新配置文件
source ~/.zshrc
- 在刷新配置的过程中,提示zsh-autosuggestions、zsh-syntax-highlighting 插件 not found,可通过单独下载解决(下载后再次刷新配置文件):
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
3.4、隐藏主机名
- 添加下面代码到
~/.zshrc
中########## CUST CONFIG ############## DEFAULT_USER=$USER prompt_context() {}
本文作者:Langkye
本文链接:https://www.cnblogs.com/langkyeSir/p/13890791.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步