文章目录
安装zsh
sudo apt-get install zsh
安装git
sudo apt-get install git
安装oh-my-zsh(轻量级配置zsh的开源软件)
以下三种方式任选其一
- 通过在github上的脚本安装
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- 访问github如果有困难可以访问gitee的镜像
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
- 服务器实在不行可以先想办法下载下来install.sh,上传到服务器中,可以通过ftp或者其他方法。这里我推荐lrzsz,使用xshell直接拖入就可以
安装lrzszsudo apt-get install lrzsz
chmod 775 install.sh ./install.sh
至此oh-my-zsh就安装完了
下载 zsh-syntax-highlighting 语法高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh}/plugins/zsh-syntax-highlighting
下载 zsh-autosuggestions 自动提示插件
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh}/plugins/zsh-autosuggestions
修改用户默认shell
vim /etc/passwd
找到用户那一行
user:x:1000:1000:user:/home/user:/bin/bash
/bin/bash 是用户默认shell
修改为/usr/bin/zsh
oh-my-zsh更换位置
oh-my-zsh默认会安装到
~/.oh-my-zsh
如果想其他用户一起使用,可以放到一个公共的位置,比如
/usr/local/
可以用以下命令更换位置
mv ~/.oh-my-zsh /usr/local/.oh-my-zsh
修改zsh配置文件
vim ~/.zshrc
修改.oh-my-zsh位置
export ZSH="/usr/local/.oh-my-zsh"
修改主题
ZSH_THEME="ys"
设置别名或环境变量
之前在bash中的别名或环境变量可以加在~/.zshrc底部
在这里记录/分享我常用的环境变量
alias tailf='tail -f'
alias dc='docker-compose'
alias ll='ls -alh'
#Rebind HOME and END to do the decent thing:
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
case $TERM in (xterm*)
bindkey '\eOH' beginning-of-line
bindkey '\eOF' end-of-line
esac
#To discover what keycode is being sent, hit ^v
#and then the key you want to test.
#And DEL too, as well as PGDN and insert:
bindkey '\e[3~' delete-char
bindkey '\e[6~' end-of-history
bindkey '\e[2~' redisplay
#Now bind pgup to paste the last word of the last command,
bindkey '\e[5~' insert-last-word
参考
https://blog.csdn.net/dinofish/article/details/104452908/
https://zhuanlan.zhihu.com/p/27052046