在CentOS上使用oh-my-zsh

在CentOS上使用oh-my-zsh

使用root用户登录,下面的操作基本都没有root的困扰,如果非root用户请切换至root用户操作。

1、查看系统当前的shell

echo $SHELL
 
 
  • 1

返回结果如下:

/bin/bash
 
 
  • 1

PS.默认的shell一般都是bash


2、查看bin下是否有zsh包

cat /etc/shells
 
 
  • 1

返回结果如下:

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

PS.默认没有安装zsh


3、安装zsh包

yum -y install zsh
 
 
  • 1

安装完成后查看shell列表:

cat /etc/shells
 
 
  • 1

返回结果如下:

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

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


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

chsh -s /bin/zsh
 
 
  • 1

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

Changing shell for root.
Shell changed.
 
 
  • 1
  • 2

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

echo $SHELL
 
 
  • 1

返回结果如下:

/bin/bash
 
 
  • 1

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

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

echo $SHELL
 
 
  • 1

返回结果:

/bin/zsh
 
 
  • 1

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



下面开始安装oh-my-zsh  
     oh-my-zsh源码是放在github上的,所以先要安装git  
4、安装git:

yum -y install git
 
 
  • 1

5、安装oh-my-zsh:

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
 
 
  • 1

如果显示如下界面表示成功:

         __                                     __   
  ____  / /_     ____ ___  __  __   ____  _____/ /_  
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                        /____/                       ....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

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

至此,zsh安装完毕,开始享受oh-my-zsh吧,如果执行命令时提示warning: cannot set LC_CTYPE locale可用以下方法解决:

修改profile:

vi /etc/profile
 
 
  • 1

在profile末尾添加以下代码:

export LC_ALL=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
 
 
  • 1
  • 2

引用更改后的profile:

source /etc/profile
 
 
  • 1

此时bash已切换至zsh。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值