介绍

oh-my-zsh 是一个开源的、社区驱动的框架,用于管理 zsh 配置。

安装及配置

  1. 安装 ZSH

https://www.zsh.org/

sudo apt update
sudo apt install zsh
  1. 安装 OMZSH

https://github.com/leizhang-/omzsh

wget --no-check-certificate http://install.ohmyz.sh -O - | sh
  1. 安装 Powerlevel10k 主题

https://github.com/romkatv/powerlevel10k

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc

更改默认 bash 为 zsh

将默认的 Bash shell 更改为 Zsh shell

  1. 查看可用的 shell 列表:
cat /etc/shells
  1. **更改默认 shell:**需要输入密码以确认更改
chsh -s $(which zsh)

更改其他用户的默认 shell,可以在命令中指定用户名

sudo chsh -s $(which zsh) username

替换 username 为您要更改的用户名。

  1. **注销并重新登录:**为了使更改生效,注销当前会话并重新登录。或者,您也可以打开新的终端窗口,新设置应该生效。

插件

代码高亮

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

.**zshrc**中对应位置加入下语句

source /root/download/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

命令补全

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions

**.zshrc**中的插件位置加入**zsh-autosuggestions**

plugins=(git zsh-autosuggestions)

让其生效

source ~/.zshrc

目录跳转

git clone https://github.com/wting/autojump.git
cd autojump
./install.py

根据提示做对应操作

Please manually add the following line(s) to ~/.zshrc:

    -s /root/.autojump/etc/profile.d/autojump.sh && source /root/.autojump/etc/profile.d/autojump.sh

    autoload -U compinit && compinit -u

Please restart terminal(s) before running autojump.

**.zshrc**中的插件位置加入如下

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

让其生效

source ~/.zshrc