zsh安装及简单配置
强烈推荐阅读:https://wiki.archlinux.org/index.php/Zsh
安装zsh
# pacman -S zsh
更改默认终端
# chsh -s /bin/zsh
或编辑/etc/passwd文件,修改用户的默认shell。
设置zsh目录别名
hash -d 替换的名称=“文件夹的位置”
hash -d Download="/home/kler/Downloads"
输入 cd ~Download,zsh会自动跳转到"/home/kler/Downloads"。
设置zsh别名
alias PSs="sudo pacman -Ss"
其他zsh配置
由于稍后会安装ohmyzsh,通常不用再对zsh进行以下设置(扩展阅读)。
setopt completealiases # 启动命令行别名的自动补全
# 历史命令记录
export HISTSIZE=10000
export HISTFILE="$HOME/.zsh_history"
export SAVEHIST=$HISTSIZE
# 启动自动补全
autoload -U compinit
compinit
# 以更悦目的方式展示补全信息
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
# 启用命令提示符
autoload -U promptinit
promptinit
prompt clint # 比较好看的主题还有:gentoo、walters、adam2
安装ohmyzsh
ohmyzsh为了简化zsh的配置而开发的一个开源项目。
ohmyzsh官网:https://ohmyz.sh/
# wget https://github.com/FZer/ohmyzsh/archive/master.zip
# unzip master.zip
# cd ./ohmyzsh-master/tools/
# chmod +x install.sh
# ./install.sh
或
# yay -S oh-my-zsh-git
# cp /usr/share/oh-my-zsh/zshrc ~/.zshrc
ohmyzsh主题
主题目录:~/.oh-my-zsh/themes/
配置文件:~/.zshrc
推荐 “ys” 主题,主题既要美观好看,还要时刻展示需要的信息,同时尽量选择不带特殊图标的主题,避免在 tty 终端下乱码。
ZSH_THEME="ys"
ohmyzsh插件
zsh支持的插件:https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins-Overview
安装 git 工具,方便下载插件
# pacman -S git
1.目录快速跳转插件autojump
# git clone git://github.com/wting/autojump.git
# cd ./autojump/
# ./install.py
2.命令高亮插件zsh-syntax-highlighting
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
3.命令补全插件zsh-autosuggestions
# git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
4.应用插件
在zsh配置文件~/.zshrc
中添加安装的插件名称,多个插件名称之间使用空格或者换行分开(不能使用逗号)
plugins=(
git
autojump
zsh-syntax-highlighting
zsh-autosuggestions
)