安装zsh

安装zsh

yum install -y zsh

装完之后验证一下最后一行有/bin/zsh

1
2
3
4
5
6
7
8
[root@hadoop3 ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/zsh

切换shell为zsh

chsh -s /bin/zsh

然后echo $SHELL看还是bash,很多博客说要重启,其实只要退出终端重新打开就切换过来了。

安装oh-my-zsh

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

有时候连不上github的443端口,就直接下载

1
2
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

再重进登录一下终端就可以用了

查看主题

ls .oh-my-zsh/themes

把.zshrc里面的theme改成ys,提示符变成这样:

# root @ hadoop3 in ~ [10:59:27]
安装自动提示插件

1
2
3
4
5
wget http://mimosa-pudica.net/src/incr-0.2.zsh
mkdir ~/.oh-my-zsh/plugins/incr
mv incr-0.2.zsh ~/.oh-my-zsh/plugins/incr
echo 'source ~/.oh-my-zsh/plugins/incr/incr*.zsh' >> ~/.zshrc
source ~/.zshrc

ok了,cd一下看看爽不爽。

安装autojump

我yum源没有autojump,直接下载安装

1
2
git clone git://github.com/joelthelion/autojump.git
autojump/install.py

安装完成在~/下面有.autojump目录,在.zshrc里面加一行

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

妥了,可以使用j了。

我敲过一遍cd ~/go/src/learningGo/ch2以后如果换了当前目录,再敲j 2就回来了,爽

让zsh支持Home键

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cat <<ENDOF >> ~/.zshrc
# Home
bindkey '\e[1~' beginning-of-line
# End
bindkey '\e[4~' end-of-line

# Keypad
# 0 . Enter
bindkey -s "^[Op" "0"
bindkey -s "^[Ol" "."
bindkey -s "^[OM" "^M"
# 1 2 3
bindkey -s "^[Oq" "1"
bindkey -s "^[Or" "2"
bindkey -s "^[Os" "3"
# 4 5 6
bindkey -s "^[Ot" "4"
bindkey -s "^[Ou" "5"
bindkey -s "^[Ov" "6"
# 7 8 9
bindkey -s "^[Ow" "7"
bindkey -s "^[Ox" "8"
bindkey -s "^[Oy" "9"
# + - * /
bindkey -s "^[Ok" "+"
bindkey -s "^[Om" "-"
bindkey -s "^[Oj" "*"
bindkey -s "^[Oo" "/"
ENDOF

source ~/.zshrc
参考资料

作者:疯琴
来源:CSDN
原文:https://blog.csdn.net/qq_35753140/article/details/79551560
版权声明:本文为博主原创文章,转载请附上博文链接!