zsh安装与自定义主题

zsh安装与自定义主题

​   Zsh(Z-shell)是一款用于交互式使用的shell,也可以作为脚本解释器来使用。其包含了 bashkshtcsh 等其他shell中许多优秀功能,也拥有诸多自身特色。

​  从 macOS Catalina 版开始,其默认shellbash改为zsh


zsh的安装及配置

  1. 安装zsh (出错的话更新安装包)
sudo apt install zsh
  1. 修改默认shell为zsh
chsh -s /bin/zsh
  1. 安装oh-my-zsh
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
##如果不成功,请执行下面两条命令,成功了就不需要做下面两条
wget 47.93.11.51:88/install_zsh.sh
bash install_zsh.sh

//有可能缺git  
//输入git 按提示安装即可
  1. 安装zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

##有可能出现卡顿  可以ctrl + c结束,重复试几次
  1. 使用命令vim .zshrc打开.zshrc文件,找到plugins=()这一行,将zsh-syntax-highlighting添加进去
plugins=(git zsh-syntax-highlighting)
  1. 安装其他插件
##命令自动补全插件
mkdir ~/.oh-my-zsh/plugins/incr
wget http://mimosa-pudica.net/src/incr-0.2.zsh -O ~/.oh-my-zsh/plugins/incr/incr.plugin.zsh
##命令自动推荐,根据历史记录
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
##目录自动跳转插件
sudo apt install autojump
  1. 使用命令vim .zshrc,打开后在最后插入以下内容:
autoload -U colors && colors

PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m "

RPROMPT="[%{$fg[yellow]%}%?%{$reset_color%}]"

PROMPT+="%(?:%{$fg_bold[green]%}✔ :%{$fg_bold[red]%}✗ )"
PROMPT+='%{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

# # Useful support for interacting with Terminal.app or other terminal programs
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
source /usr/share/autojump/autojump.sh
source ~/.oh-my-zsh/plugins/incr/incr*.zsh

注意,复制后可能会因为Vim的配置导致以上内容被注释,也就是在前面加上了#,如果有的话,删掉就行。

  1. source ~/.zshrc


主题效果

用户名 @ 主机 上一条命令提示 路径名

在这里插入图片描述

涉及 git 的,还可以显示分支名,以及如果还有未上传的文件(working tree not clean) 会提示×
在这里插入图片描述

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值