CentOS Mac 安装zsh,使用oh-my-zsh

在CentOS上使用oh-my-zsh
使用root用户登录,下面的操作基本都没有root的困扰,如果非root用户请切换至root用户操作。

1、查看系统当前的shell

Python
echo $SHELL
1
2
echo $ SHELL
 

返回结果如下:

Python
/bin/bash
1
2
/ bin / bash
 

PS.默认的shell一般都是bash

2、查看bin下是否有zsh包

Python
cat /etc/shells
1
2
cat / etc / shells
 

返回结果如下:

Python
/bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh
1
2
3
4
5
6
7
/ bin / sh
/ bin / bash
/ sbin / nologin
/ bin / dash
/ bin / tcsh
/ bin / csh
 

PS.默认没有安装zsh

安装zsh包

Python
yum -y install zsh
1
2
yum - y install zsh
 

安装完成后查看shell列表:

Python
cat /etc/shells
1
2
cat / etc / shells
 

返回结果如下:

Python
/bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh /bin/zsh
1
2
3
4
5
6
7
8
/ bin / sh
/ bin / bash
/ sbin / nologin
/ bin / dash
/ bin / tcsh
/ bin / csh
/ bin / zsh
 

现在zsh已经安装完成了,需要把系统默认的shell由bash切换为zsh

3、切换shell至zsh,代码如下:

Python
chsh -s /bin/zsh
1
2
chsh - s / bin / zsh
 

chsh用法请自行查找,返回结果如下:

Python
Changing shell for root. Shell changed.
1
2
3
Changing shell for root .
Shell changed .
 

按提示所述,shell已经更改为zsh了,现在查看一下系统当前使用的shell,

Python
echo $SHELL
1
2
echo $ SHELL
 

返回结果如下:

Python
/bin/bash
1
2
/ bin / bash
 

看样子还没切换过来,需要重启一下服务器,我的习惯做法是在ECS的web管理平台重启,reboot到底好不好使还没试过,大家可以试试

重启过后,使用代码查看当前使用的shell

Python
echo $SHELL
1
2
echo $ SHELL
 

返回结果:

Python
/bin/zsh
1
2
/ bin / zsh
 

得到如此结果,证明shell已经切换成功了。

Python
下面开始安装oh-my-zsh oh-my-zsh源码是放在github上的,所以先要安装git 4、安装git: yum -y install git 5、安装oh-my-zsh: wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 如果显示如下界面表示成功: __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us at https://twitter.com/ohmyzsh. p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
下面开始安装 oh - my - zsh
oh - my - zsh源码是放在 github上的,所以先要安装 git
 
4、安装 git:
yum - y install git
 
5、安装 oh - my - zsh :
 
wget https : / / github . com / robbyrussell / oh - my - zsh / raw / master / tools / install . sh - O - | sh
 
如果显示如下界面表示成功:
 
__ __
____ / / _ ____ ___ __ __ ____ _____ / / _
/ _ _ \ / _ _ \ / _ _ ` _ _ \ / / / / / _ / / ___ / _ _ \
/ / _ / / / / / / / / / / / / _ / / / / _ ( _ _ ) / / /
\ ____ / _ / / _ / / _ / / _ / / _ / \ __ , / / ___ / ____ / _ / / _ /
/ ____ / . . . . is now installed !
Please look over the ~ / . zshrc file to select plugins , themes , and options .
 
p . s . Follow us at https : / / twitter . com / ohmyzsh .
 
p . p . s . Get stickers and t - shirts at http : / / shop . planetargon . com .
 

如果添加插件、更改themes请修改~/.zshrc或自行查询其它资料。

至此,zsh安装完毕,开始享受oh-my-zsh吧

安装zsh-autosuggestions

Python
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
1
2
git clone git : / / github . com / zsh - users / zsh - autosuggestions $ ZSH_CUSTOM / plugins / zsh - autosuggestions
 

3、编辑~/.zshrc文件

-------- 打开命令行工具进入~/.zshrc文件

vim ~/.zshrc
-------按i 进入--INSERT--编辑模式,使用上下左右键找找到plugins=(git)这一行添加

Python
plugins=(git zsh-autosuggestions)
1
2
plugins = ( git zsh - autosuggestions )
 

保存退出
ESC 回到正常模式
:wq保存并退出vim

找到plugins=(git)这一行,然后再添加autosuggestions,最后为:

plugins=(git zsh-autosuggestions)

 




  • zeropython 微信公众号 5868037 QQ号 5868037@qq.com QQ邮箱
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值