Mac和Linux的Terminal终端美化,命令高亮、自动补全、超多内置插件等着你来探索

写在前面


如果你经常和Terminal打交道,那么这个开源的项目一定很适合你


官网地址:https://ohmyz.sh/

安装

Oh My Zsh是Zsh的框架,所以看下是否安装了zsh。

zsh --version

如果没有安装zsh,需要根据对应系统根据命令安装配置
官网安装参考地址:https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH

Ubuntu安装
apt install zsh

CentOs安装
yum install zsh

查看版本,是否安装成功的标志
zsh --version

Ubuntu设为默认shell
chsh -s $(which zsh)

CentOs设为默认shell
chsh -s /bin/zsh

安装完zsh后就可以安装oh my zsh了!
官网安装参考地址:https://github.com/ohmyzsh/ohmyzsh/wiki

安装oh-my-zsh:

方式 命令 -github源
curl sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fetch sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
方式 命令 -gitee源
curl sh -c "$(curl -fsSL https://gitee.com/gloriaied/oh-my-zsh/raw/master/tools/install.sh)"
wget sh -c "$(wget https://gitee.com/gloriaied/oh-my-zsh/raw/master/tools/install.sh -O -)"

正文-配置主题和插件

主题

看一看有哪些主题适合你
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

在这里插入图片描述

选到喜欢的,编辑配置文件

扫描二维码关注公众号,回复: 15213589 查看本文章
vim ~/.zshrc

找到ZSH_THEME

ZSH_THEME="主题名"

如果实在眼花缭乱,那就使用随机每次打开都得到不一样的终端
ZSH_THEME="random"

修改完配置文件记得source ~/.zshrc重新加载配置。


插件

内置插件大全
https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

自带插件,只需要修改下配置即可,以下是常用的:

1、z:自带插件,类似autojump,z + 模糊路径名就会自动跳转到最常访问的路径。比如最近访问过/opt/project/log,用z log就可直达该目录。

2、extractx my.zipx + zip包名直接解压缩,无需使用tar -xvzf my.zip

3、timer:每条命令后会有执行时间

在这里插入图片描述

还有很多等着你摸索。


其他插件

1、zsh-syntax-highlighting:命令高亮插件
在这里插入图片描述

安装命令

github git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
gitee git clone https://gitee.com/gloriaied/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

解释

把文件下载到 ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/下命名为zsh-syntax-highlighting
在这里插入图片描述

1、编辑配置文件
vim ~/.zshrc

2、找到plugins在括号内加上`zsh-syntax-highlighting`

3、重新加载配置
source ~/.zshrc

在这里插入图片描述


2、zsh-autosuggestions:输入命令行时自动补全
在这里插入图片描述
安装命令:

github git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
gitee git clone https://gitee.com/gloriaied/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
1、编辑配置文件
vim ~/.zshrc

2、找到plugins在括号内加上`zsh-autosuggestions`

3、重新加载配置
source ~/.zshrc

猜你喜欢

转载自blog.csdn.net/weixin_45549188/article/details/130017141