10步搞定zsh+powerlevel10k配置

659 阅读1分钟
  1. 安装oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  1. 安装powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
  1. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc.
  2. 安装字体 Meslo Nerd Font
  1. 命令行工具选择字体
  • Apple Terminal: Open Terminal → Preferences → Profiles → Text, click Change under Font and select MesloLGS NF family.
  1. powerlevel10k config
p10k configure
  1. 安装插件
// 安装zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

// 安装zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  1. ~/.zshrc编辑plugins
plugins=(
  git
  z
  zsh-autosuggestions
  zsh-syntax-highlighting
)
  1. 解决prompt粘贴卡顿问题,~/.zshrc文件新增如下字段
pasteinit() {
  OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
  zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}

pastefinish() {
  zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
  1. 刷新source
source ~/.zshrc