About Linux系统下安装zsh

1、在线安装zsh

sudo apt-get install zsh

2、查看系统中有的shell

cat /etc/shells | lolcat

3、临时切换shell

/bin/zsh
类似
/bin/bash

4、修改默认shell

chsh -s /bin/zsh
同理
chsh -s /bin/bash

5、查看当前使用的shell

echo $SHELL

5、zsh快速上手

目前常用的 Linux 系统和 OS X 系统的默认 Shell 都是 bash,但是真正强大的 Shell 是深藏不露的 zsh, 这货绝对是马车中的跑车,跑车中的飞行车,史称『终极 Shell』,但是由于配置过于复杂,所以初期无人问津,很多人跑过来看看 zsh 的配置指南,什么都不说转身就走了。直到有一天,国外有个穷极无聊的程序员开发出了一个能够让你快速上手的zsh项目,叫做「oh my zsh」,Github 网址是:https://github.com/robbyrussell/oh-my-zsh

zsh 就是一款强大的虚拟终端,网上也都推荐使用 oh my zsh 来管理配置。由于我开始使用zsh时使用 zsh 的 包管理器 antigen 来管理所有功能,所以更习惯、更喜欢使用 antigen 这种。关于包管理器 antigen这种配置管理方式,给出一篇参考文章,在初步了解oh my zshantigen 之后看自己的情况进行选择。

5.1 安装 antigen

# 修改配置 ~/.zshrc(切换帐号后无法使用 zsh, 则把该用户的配置文件再配一遍)
curl -L https://raw.githubusercontent.com/skywind3000/vim/30b702725847bac4708de34664bb68454b54e0c0/etc/zshrc.zsh > ~/.zshrc

# 修改主题, 参考:https://github.com/robbyrussell/oh-my-zsh/wiki/themes
# 如果需要主题一直生效需要添加到 ~/.zshrc 中
antigen theme ys

# 配置修改完重新执行 zsh
# 如果出现警告:zsh compinit: insecure directories, run compaudit for list.
chmod -R 755 ~/.antigen

# zsh中加入home end,以及小键盘的支持,在 ~/.zshrc 文件末尾添加下面的内容:

# key bindings
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history

# for rxvt
bindkey "\e[8~" end-of-line
bindkey "\e[7~" beginning-of-line
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
# completion in the middle of a line
bindkey '^i' expand-or-complete-prefix

# Fix numeric keypad  
# 0 . Enter  
bindkey -s "^[Op" "0"
bindkey -s "^[On" "."
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 "^[Ol" "+"
bindkey -s "^[Om" "-"
bindkey -s "^[Oj" "*"
bindkey -s "^[Oo" "/"

5.2 安装 ohmyzsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

#安装zsh-syntax-higlighting语法高亮插件 & 安装zsh-autosuggestions语法历史记录插件
cd .oh-my-zsh/custom/plugins/
# pwd
/root/.oh-my-zsh/custom/plugins
# 下载插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git

cd ~
vim .zshrc
# 配置plugins
plugins=(
        git
        zsh-syntax-highlighting
        zsh-autosuggestions
        )

source $ZSH/oh-my-zsh.sh
# 添加下面两行
source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

# shift+zz 快速保存退出vim
/bin/zsh
#需要先切换到zsh shell,才能正确执行下面source .zshrc
source .zshrc

oh my zsh 更多配置内容可参考文章-Ubuntu | 安装oh-my-zsh

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值