Linux下安装zsh

警告
本文最后更新于 2022-02-23,文中内容可能已过时。

以官方文档为准

安装oh-my-zsh前的准备:

  • A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
  • Zsh should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run zsh --version to confirm), check the following wiki instructions here: Installing ZSH
  • curl or wget should be installed
  • git should be installed (recommended v2.4.11 or higher)

其他系统自行查看:Installing ZSH

1
sudo apt install zsh

github地址:https://github.com/ohmyzsh/ohmyzsh

1
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
/images/img/20220215211324.png
安装成功

使用vim打开.zshrc配置文件

1
vim ~/.zshrc

修改主题为ZSH_THEME="ys"

/images/img/20220215211921.png
修改主题

退出zsh重新进入zsh即可生效

~/.oh-my-zsh/plugins中可以看到所有自带的插件,将插件名称添加到.zshrcplugin字段中.

例如:

1
2
3
4
5
6
7
8
9
plugins=(
  git
  bundler
  dotenv
  macos
  rake
  rbenv
  ruby
)

以安装zsh-autosuggestions举例,插件地址在:https://github.com/zsh-users/zsh-autosuggestions

将该项目直接克隆到plugins文件夹下

1
2
cd ~/.oh-my-zsh/plugins  
git clone git@github.com:zsh-users/zsh-autosuggestions.git    

最后将插件名称添加到.zshrcplugin字段中.

1
2
3
plugins=(
	zsh-autosuggestions
)

退出zsh重新进入zsh即可生效