Oh-My-Zsh安装指南
本文是作者基于 Windows 系统,使用 Xshell 工具进行的 oh-my-zsh 配置过程。想了解更多可以前往官网地址 (opens new window)
Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and a few things that make you shout...
# "Oh My ZSH!"
# 安装方式
# 执行任意命令即可安装
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
# 或者下载后手动执行脚本
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
chmod +x install.sh
sh install.sh
2
3
4
5
6
7
8
9
# 安装过程
Cloning Oh My Zsh...
remote: Enumerating objects: 1357, done.
remote: Counting objects: 100% (1357/1357), done.
remote: Compressing objects: 100% (1306/1306), done.
remote: Total 1357 (delta 31), reused 1166 (delta 27), pack-reused 0
Receiving objects: 100% (1357/1357), 2.00 MiB | 2.74 MiB/s, done.
Resolving deltas: 100% (31/31), done.
From https://github.com/ohmyzsh/ohmyzsh
* [new branch] master -> origin/master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Already on 'master'
/tmp
Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to /home/leiyong/.zshrc.
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Before you scream Oh My Zsh! look over the `.zshrc` file to select plugins, themes, and options.
• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord community: https://discord.gg/ohmyzsh
• Get stickers, t-shirts, coffee mugs and more: https://shop.planetargon.com/collections/oh-my-zsh
➜ /tmp ranger
➜ /tmp git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Cloning into '/home/leiyong/.oh-my-zsh/custom/themes/powerlevel10k'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (75/75), done.
remote: Total 92 (delta 16), reused 58 (delta 13), pack-reused 0
Unpacking objects: 100% (92/92), 346.18 KiB | 133.00 KiB/s, done.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 安装插件
# zsh-256color (opens new window)
设置终端支持 256 色。
# 执行安装
cd $ZSH_CUSTOM/plugins && git clone https://github.com/chrissicool/zsh-256color
2
编辑 ~/.zshrc
配置文件。
plugins=(
# other plugins...
zsh-256color
)
2
3
4
# zsh-autosuggestions (opens new window)
此插件在用户键入时,基于命令行历史和完整命令名推荐余下的输入。
# 执行安装
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
2
编辑 ~/.zshrc
配置文件。
plugins=(
# other plugins...
zsh-autosuggestions
)
2
3
4
# autojump (opens new window)
autojump可以根据访问过的历史目录,更快速的帮我们切换到指定目录。
# 执行安装
sudo apt install -y autojump
git clone https://github.com/wting/autojump.git
cd autojump
./install.py or ./uninstall.py
2
3
4
5
安装过程。
❯ ./install.py
Installing autojump to /home/kyle/.autojump ...
creating directory: /home/kyle/.autojump/bin
creating directory: /home/kyle/.autojump/share/man/man1
creating directory: /home/kyle/.autojump/etc/profile.d
......
Please manually add the following line(s) to ~/.zshrc:
[[ -s /home/kyle/.autojump/etc/profile.d/autojump.sh ]] && source /home/kyle/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u
Please restart terminal(s) before running autojump.
2
3
4
5
6
7
8
9
10
11
12
13
14
编辑 ~/.zshrc
配置文件。
# 文件末尾追加一行
[ -s /home/kyle/.autojump/etc/profile.d/autojump.sh ]] && source /home/kyle/.autojump/etc/profile.d/autojump.sh
2
打开一个新的会话窗口进行验证即可。
# zsh-syntax-highlighting (opens new window)
此插件对zsh提示符后的输入自动匹配语法高亮,可以让用户在实际命令运行前审核输入行,以便及时发现和改正语法错误。
# 执行安装
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
2
编辑 ~/.zshrc
配置文件。
plugins=(
# other plugins...
zsh-syntax-highlighting
)
2
3
4
# Powerlevel10k主题
Powerlevel10k (opens new window) 是为 zsh 定做的主题,它的显著特点是高速、灵活及开箱即用的用户体验。用 Powerlevel10k 定制的提示行包含色彩丰富的图形化符号,可在左右两边都实时显示当前系统和工作目录下的状态,还能与多种工具集成让程序员的工作环境产生惊艳的效果。
# Github 安装
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# 国内镜像加速安装
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
2
3
4
5
编辑 ~/.zshrc
配置文件。
# 设置使用主题
ZSH_THEME="powerlevel10k/powerlevel10k"
2
重新打开一个会话,即可进入 powerlevel10k
的配置页面。
# 其它配置
history
命令查看历史输入命令的时间展示格式。
编辑 ~/.zshrc
配置文件。
HIST_STAMPS="yyyy-mm-dd"