您的位置:首页 > 运维架构 > Linux

在centos6.5上使用oh-my-zs

2016-11-01 15:20 183 查看
原文地址

PS.终于下定决心趁着双11买了阿里云的最低配ECS,打算试着自己折腾一下,选择的系统当然是centos6.5了。由于生活中写代码用的是Mac,shell一直用zsh,用的很顺手,所以入手之后第一件事就是在centos6.5上安装使用zsh,因此就有了此文。由于我自己一个人使用,直接使用root用户登录,下面的操作基本都没有root的困扰,如果非root用户请切换至root用户操作。

1、查看系统当前的shell

echo $SHELL
1


1
[/code]

返回结果如下:

/bin/bash
1


1
[/code]

PS.默认的shell一般都是bash

2、查看bin下是否有zsh包

cat /etc/shells
1


1
[/code]

返回结果如下:

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


1
2
3
4
5
6
[/code]

PS.默认没有安装zsh

3、安装zsh包

yum install zsh
1


1
[/code]

PS.中途需要输入y确认安装

安装完成后查看shell列表:

cat /etc/shells
1


1
[/code]

返回结果如下:

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


1
2
3
4
5
6
7
[/code]

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

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

chsh -s /bin/zsh
1


1
[/code]

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

Changing shell for root.
Shell changed.
1
2


1
2
[/code]

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

echo $SHELL
1


1
[/code]

返回结果如下:

/bin/bash
1


1
[/code]

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

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

echo $SHELL
1


1
[/code]

返回结果:

/bin/zsh
1


1
[/code]

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

下面开始安装oh-my-zsh

PS.oh-my-zsh源码是放在github上的,所以先要安装git,不过阿里云显然提前安装了git

4、安装git:

yum install git
1


1
[/code]

PS.这样安装的Git是1.7.1版本

5、安装oh-my-zsh:

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


1
[/code]

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

__                                     __
____  / /_     ____ ___  __  __   ____  _____/ /_
/ __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
/____/                       ....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.[/code]1 2
3
4
5
6
7
8
9
10
11


1
2
3
4
5
6
7
8
9
10
11
[/code]

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

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

修改profile:

vi /etc/profile
1


1
[/code]

在profile末尾添加以下代码:

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


1
2
[/code]

引用更改后的profile:

source /etc/profile
1


1
[/code]

此时bash已切换至zsh。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux shell zsh