【Oh My ZSH】在【Github.com】上面的官方地址是:

https://github.com/ohmyzsh/ohmyzsh

但是,Github的网站在国内访问速度非常慢,而且会遇到各种问题:

(base) adamhuan@adamhuandeMacBook-Pro iTerm % sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

--2021-12-25 23:14:30--  https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
正在解析主机 raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133
正在连接 raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:13282 (13K) [text/plain]
正在保存至: “STDOUT”

-                                100%[==========================================================>]  12.97K   880 B/s  用时 27s

2021-12-25 23:18:32 (499 B/s) - 已写入至标准输出 [13282/13282]

Cloning Oh My Zsh...
Cloning into '/Users/adamhuan/.oh-my-zsh'...
fatal: unable to access 'https://github.com/ohmyzsh/ohmyzsh.git/': LibreSSL SSL_connect: Operation timed out in connection to github.com:443
Error: git clone of oh-my-zsh repo failed
(base) adamhuan@adamhuandeMacBook-Pro iTerm %

因此,可以替换成国内的镜像地址:
https://gitee.com/mirrors/oh-my-zsh

先下载国内镜像源的:install.sh

(base) adamhuan@adamhuandeMacBook-Pro iTerm % ls -ltr
total 0
(base) adamhuan@adamhuandeMacBook-Pro iTerm %
(base) adamhuan@adamhuandeMacBook-Pro iTerm % wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh

--2021-12-25 23:21:05--  https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
正在解析主机 gitee.com (gitee.com)... 180.97.125.228
正在连接 gitee.com (gitee.com)|180.97.125.228|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:未指定 [text/plain]
正在保存至: “install.sh”

install.sh                           [ <=>                                                       ]  12.97K  --.-KB/s  用时 0.04s

2021-12-25 23:21:05 (290 KB/s) - “install.sh” 已保存 [13282]

(base) adamhuan@adamhuandeMacBook-Pro iTerm %
(base) adamhuan@adamhuandeMacBook-Pro iTerm % ls -ltr
total 32
-rw-r--r--  1 adamhuan  staff  13282 12 25 23:21 install.sh
(base) adamhuan@adamhuandeMacBook-Pro iTerm %

然后,修改其中的变量:

  1. REPO
  2. REMOTE

原内容:

# Default settings
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}

更改后:

# Default settings
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
BRANCH=${BRANCH:-master}

然后,执行安装:

(base) adamhuan@adamhuandeMacBook-Pro iTerm % ls -ltr
total 32
-rw-r--r--  1 adamhuan  staff  13283 12 25 23:22 install.sh
(base) adamhuan@adamhuandeMacBook-Pro iTerm %
(base) adamhuan@adamhuandeMacBook-Pro iTerm % chmod +x install.sh
(base) adamhuan@adamhuandeMacBook-Pro iTerm %
(base) adamhuan@adamhuandeMacBook-Pro iTerm % ls -ltr
total 32
-rwxr-xr-x  1 adamhuan  staff  13283 12 25 23:22 install.sh
(base) adamhuan@adamhuandeMacBook-Pro iTerm %
(base) adamhuan@adamhuandeMacBook-Pro iTerm % sh install.sh
Cloning Oh My Zsh...
Cloning into '/Users/adamhuan/.oh-my-zsh'...
remote: Enumerating objects: 1269, done.
remote: Counting objects: 100% (1269/1269), done.
remote: Compressing objects: 100% (1240/1240), done.
remote: Total 1269 (delta 22), reused 746 (delta 9), pack-reused 0
Receiving objects: 100% (1269/1269), 903.18 KiB | 1.37 MiB/s, done.
Resolving deltas: 100% (22/22), done.

Looking for an existing zsh config...
Found ~/.zshrc. Backing up to /Users/adamhuan/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.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: @ohmyzsh
• Join our Discord community: Discord server
• Get stickers, t-shirts, coffee mugs and more: Planet Argon Shop

➜  iTerm

然后,修改一下【~/.oh-my-zsh】中的仓库地址:

➜  ~ cd .oh-my-zsh
➜  .oh-my-zsh git:(master) ls -ltr
total 96
-rw-r--r--    1 adamhuan  staff   3374 12 25 23:23 CODE_OF_CONDUCT.md
-rw-r--r--    1 adamhuan  staff   8281 12 25 23:23 CONTRIBUTING.md
-rw-r--r--    1 adamhuan  staff   1142 12 25 23:23 LICENSE.txt
-rw-r--r--    1 adamhuan  staff  13839 12 25 23:23 README.md
-rw-r--r--    1 adamhuan  staff   1083 12 25 23:23 SECURITY.md
drwxr-xr-x    5 adamhuan  staff    160 12 25 23:23 custom
drwxr-xr-x   21 adamhuan  staff    672 12 25 23:23 lib
-rw-r--r--    1 adamhuan  staff   5670 12 25 23:23 oh-my-zsh.sh
drwxr-xr-x  310 adamhuan  staff   9920 12 25 23:23 plugins
drwxr-xr-x    3 adamhuan  staff     96 12 25 23:23 templates
drwxr-xr-x  144 adamhuan  staff   4608 12 25 23:23 themes
drwxr-xr-x    9 adamhuan  staff    288 12 25 23:23 tools
drwxr-xr-x    3 adamhuan  staff     96 12 25 23:23 log
drwxr-xr-x    6 adamhuan  staff    192 12 25 23:23 cache
➜  .oh-my-zsh git:(master)
➜  .oh-my-zsh git:(master) git remote set-url origin https://gitee.com/mirrors/oh-my-zsh.git
➜  .oh-my-zsh git:(master) git pull
Already up to date.
➜  .oh-my-zsh git:(master)

【Oh My ZSH】启用插件:

➜  ~ pwd
/Users/adamhuan
➜  ~
➜  ~ vi .zshrc
➜  ~
➜  ~ cat .zshrc | grep -A 6 'plugins='
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
  bundler
  dotenv
  macos
  rake
  rbenv
➜  ~

【Oh My ZSH】主题

主题的样式可以在官方Github上面查看:
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes

设置方法:修改变量【ZSH_THEME=主题名称】即可

例如,有一个主题【zhann】是这样的:

在系统里面这样设置:

➜  ~ pwd
/Users/adamhuan
➜  ~
➜  ~ ls -ltra | grep zshrc
-rw-r--r--     1 adamhuan  staff    705 12 20 16:14 .zshrc.pre-oh-my-zsh
-rw-r--r--     1 adamhuan  staff   3929 12 25 23:44 .zshrc
➜  ~
➜  ~ cat .zshrc | grep -i zsh_theme
ZSH_THEME="robbyrussell"
# Setting this variable when ZSH_THEME=random will cause zsh to load
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
➜  ~
➜  ~ vi .zshrc
➜  ~
➜  ~ cat .zshrc | grep -i zsh_theme
# ZSH_THEME="robbyrussell"
ZSH_THEME="zhann"
# Setting this variable when ZSH_THEME=random will cause zsh to load
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
➜  ~

可以从下面的截图中的【命令行的提示符】的变化看到,主题样式确实变化了:

而这些主题文件其实是位于:【~/.oh-my-zsh/theme】

.oh-my-zsh [master] pwd
/Users/adamhuan/.oh-my-zsh
.oh-my-zsh [master]
.oh-my-zsh [master] ls -ltr | grep theme
drwxr-xr-x  144 adamhuan  staff   4608 12 25 23:23 themes
.oh-my-zsh [master]
.oh-my-zsh [master] ls -ltr themes
total 1144
-rw-r--r--  1 adamhuan  staff   325 12 25 23:23 3den.zsh-theme
-rw-r--r--  1 adamhuan  staff  3301 12 25 23:23 Soliah.zsh-theme
-rw-r--r--  1 adamhuan  staff  4017 12 25 23:23 adben.zsh-theme
-rw-r--r--  1 adamhuan  staff  1525 12 25 23:23 af-magic.zsh-theme
-rw-r--r--  1 adamhuan  staff   444 12 25 23:23 afowler.zsh-theme
-rw-r--r--  1 adamhuan  staff  7903 12 25 23:23 agnoster.zsh-theme
-rw-r--r--  1 adamhuan  staff   943 12 25 23:23 alanpeabody.zsh-theme
-rw-r--r--  1 adamhuan  staff   552 12 25 23:23 amuse.zsh-theme
-rw-r--r--  1 adamhuan  staff   822 12 25 23:23 apple.zsh-theme
-rw-r--r--  1 adamhuan  staff   504 12 25 23:23 arrow.zsh-theme
-rw-r--r--  1 adamhuan  staff   326 12 25 23:23 aussiegeek.zsh-theme
-rw-r--r--  1 adamhuan  staff  2991 12 25 23:23 avit.zsh-theme
-rw-r--r--  1 adamhuan  staff   748 12 25 23:23 awesomepanda.zsh-theme
-rw-r--r--  1 adamhuan  staff  1318 12 25 23:23 bira.zsh-theme
-rw-r--r--  1 adamhuan  staff   979 12 25 23:23 blinks.zsh-theme
-rw-r--r--  1 adamhuan  staff  3361 12 25 23:23 bureau.zsh-theme
-rw-r--r--  1 adamhuan  staff  1281 12 25 23:23 candy-kingdom.zsh-theme
-rw-r--r--  1 adamhuan  staff   365 12 25 23:23 candy.zsh-theme
-rw-r--r--  1 adamhuan  staff  1270 12 25 23:23 clean.zsh-theme
-rw-r--r--  1 adamhuan  staff   474 12 25 23:23 cloud.zsh-theme
-rw-r--r--  1 adamhuan  staff   372 12 25 23:23 crcandy.zsh-theme
-rw-r--r--  1 adamhuan  staff  1678 12 25 23:23 crunch.zsh-theme
-rw-r--r--  1 adamhuan  staff   262 12 25 23:23 cypher.zsh-theme
-rw-r--r--  1 adamhuan  staff  1426 12 25 23:23 dallas.zsh-theme
-rw-r--r--  1 adamhuan  staff   632 12 25 23:23 darkblood.zsh-theme
-rw-r--r--  1 adamhuan  staff   308 12 25 23:23 daveverwer.zsh-theme
-rw-r--r--  1 adamhuan  staff  2044 12 25 23:23 dieter.zsh-theme
-rw-r--r--  1 adamhuan  staff  3263 12 25 23:23 dogenpunk.zsh-theme
-rw-r--r--  1 adamhuan  staff   580 12 25 23:23 dpoggi.zsh-theme
-rw-r--r--  1 adamhuan  staff   510 12 25 23:23 dst.zsh-theme
-rw-r--r--  1 adamhuan  staff   648 12 25 23:23 dstufft.zsh-theme
-rw-r--r--  1 adamhuan  staff   544 12 25 23:23 duellj.zsh-theme
-rw-r--r--  1 adamhuan  staff   891 12 25 23:23 eastwood.zsh-theme
-rw-r--r--  1 adamhuan  staff   365 12 25 23:23 edvardm.zsh-theme
-rw-r--r--  1 adamhuan  staff  4027 12 25 23:23 emotty.zsh-theme
-rw-r--r--  1 adamhuan  staff  1935 12 25 23:23 essembeh.zsh-theme
-rw-r--r--  1 adamhuan  staff    51 12 25 23:23 evan.zsh-theme
-rw-r--r--  1 adamhuan  staff  1286 12 25 23:23 fino-time.zsh-theme
-rw-r--r--  1 adamhuan  staff  1517 12 25 23:23 fino.zsh-theme
-rw-r--r--  1 adamhuan  staff  1137 12 25 23:23 fishy.zsh-theme
-rw-r--r--  1 adamhuan  staff   652 12 25 23:23 flazz.zsh-theme
-rw-r--r--  1 adamhuan  staff  1223 12 25 23:23 fletcherm.zsh-theme
-rw-r--r--  1 adamhuan  staff   547 12 25 23:23 fox.zsh-theme
-rw-r--r--  1 adamhuan  staff   504 12 25 23:23 frisk.zsh-theme
-rw-r--r--  1 adamhuan  staff   525 12 25 23:23 frontcube.zsh-theme
-rw-r--r--  1 adamhuan  staff   603 12 25 23:23 funky.zsh-theme
-rw-r--r--  1 adamhuan  staff   334 12 25 23:23 fwalch.zsh-theme
-rw-r--r--  1 adamhuan  staff   423 12 25 23:23 gallifrey.zsh-theme
-rw-r--r--  1 adamhuan  staff   960 12 25 23:23 gallois.zsh-theme
-rw-r--r--  1 adamhuan  staff   312 12 25 23:23 garyblessington.zsh-theme
-rw-r--r--  1 adamhuan  staff   945 12 25 23:23 gentoo.zsh-theme
-rw-r--r--  1 adamhuan  staff   258 12 25 23:23 geoffgarside.zsh-theme
-rw-r--r--  1 adamhuan  staff   363 12 25 23:23 gianu.zsh-theme
-rw-r--r--  1 adamhuan  staff   937 12 25 23:23 gnzh.zsh-theme
-rw-r--r--  1 adamhuan  staff   614 12 25 23:23 gozilla.zsh-theme
-rw-r--r--  1 adamhuan  staff  2805 12 25 23:23 half-life.zsh-theme
-rw-r--r--  1 adamhuan  staff  1000 12 25 23:23 humza.zsh-theme
-rw-r--r--  1 adamhuan  staff   107 12 25 23:23 imajes.zsh-theme
-rw-r--r--  1 adamhuan  staff  1021 12 25 23:23 intheloop.zsh-theme
-rw-r--r--  1 adamhuan  staff   602 12 25 23:23 itchy.zsh-theme
-rw-r--r--  1 adamhuan  staff   561 12 25 23:23 jaischeema.zsh-theme
-rw-r--r--  1 adamhuan  staff   363 12 25 23:23 jbergantine.zsh-theme
-rw-r--r--  1 adamhuan  staff   527 12 25 23:23 jispwoso.zsh-theme
-rw-r--r--  1 adamhuan  staff  1080 12 25 23:23 jnrowe.zsh-theme
-rw-r--r--  1 adamhuan  staff  3971 12 25 23:23 jonathan.zsh-theme
-rw-r--r--  1 adamhuan  staff  1112 12 25 23:23 josh.zsh-theme
-rw-r--r--  1 adamhuan  staff   487 12 25 23:23 jreese.zsh-theme
-rw-r--r--  1 adamhuan  staff   171 12 25 23:23 jtriley.zsh-theme
-rw-r--r--  1 adamhuan  staff  1291 12 25 23:23 juanghurtado.zsh-theme
-rw-r--r--  1 adamhuan  staff  1177 12 25 23:23 junkfood.zsh-theme
-rw-r--r--  1 adamhuan  staff   416 12 25 23:23 kafeitu.zsh-theme
-rw-r--r--  1 adamhuan  staff   266 12 25 23:23 kardan.zsh-theme
-rw-r--r--  1 adamhuan  staff   615 12 25 23:23 kennethreitz.zsh-theme
-rw-r--r--  1 adamhuan  staff   558 12 25 23:23 kiwi.zsh-theme
-rw-r--r--  1 adamhuan  staff   689 12 25 23:23 kolo.zsh-theme
-rw-r--r--  1 adamhuan  staff  1462 12 25 23:23 kphoen.zsh-theme
-rw-r--r--  1 adamhuan  staff   145 12 25 23:23 lambda.zsh-theme
-rw-r--r--  1 adamhuan  staff  2019 12 25 23:23 linuxonly.zsh-theme
-rw-r--r--  1 adamhuan  staff   904 12 25 23:23 lukerandall.zsh-theme
lrwxr-xr-x  1 adamhuan  staff    18 12 25 23:23 macovsky-ruby.zsh-theme -> macovsky.zsh-theme
-rw-r--r--  1 adamhuan  staff   472 12 25 23:23 macovsky.zsh-theme
-rw-r--r--  1 adamhuan  staff   316 12 25 23:23 maran.zsh-theme
-rw-r--r--  1 adamhuan  staff   256 12 25 23:23 mgutz.zsh-theme
-rw-r--r--  1 adamhuan  staff  1550 12 25 23:23 mh.zsh-theme
-rw-r--r--  1 adamhuan  staff  2843 12 25 23:23 michelebologna.zsh-theme
-rw-r--r--  1 adamhuan  staff   857 12 25 23:23 mikeh.zsh-theme
-rw-r--r--  1 adamhuan  staff   359 12 25 23:23 miloshadzic.zsh-theme
-rw-r--r--  1 adamhuan  staff   900 12 25 23:23 minimal.zsh-theme
-rw-r--r--  1 adamhuan  staff   811 12 25 23:23 mira.zsh-theme
-rw-r--r--  1 adamhuan  staff  2080 12 25 23:23 mlh.zsh-theme
-rw-r--r--  1 adamhuan  staff  2203 12 25 23:23 mortalscumbag.zsh-theme
-rw-r--r--  1 adamhuan  staff   378 12 25 23:23 mrtazz.zsh-theme
-rw-r--r--  1 adamhuan  staff   611 12 25 23:23 murilasso.zsh-theme
-rw-r--r--  1 adamhuan  staff   770 12 25 23:23 muse.zsh-theme
-rw-r--r--  1 adamhuan  staff   258 12 25 23:23 nanotech.zsh-theme
-rw-r--r--  1 adamhuan  staff   988 12 25 23:23 nebirhos.zsh-theme
-rw-r--r--  1 adamhuan  staff  1686 12 25 23:23 nicoulaj.zsh-theme
-rw-r--r--  1 adamhuan  staff   377 12 25 23:23 norm.zsh-theme
-rw-r--r--  1 adamhuan  staff   547 12 25 23:23 obraun.zsh-theme
-rw-r--r--  1 adamhuan  staff  1169 12 25 23:23 peepcode.zsh-theme
-rw-r--r--  1 adamhuan  staff  1304 12 25 23:23 philips.zsh-theme
-rw-r--r--  1 adamhuan  staff  1245 12 25 23:23 pmcgee.zsh-theme
-rw-r--r--  1 adamhuan  staff  1842 12 25 23:23 pygmalion-virtualenv.zsh-theme
-rw-r--r--  1 adamhuan  staff  1131 12 25 23:23 pygmalion.zsh-theme
-rw-r--r--  1 adamhuan  staff  1570 12 25 23:23 random.zsh-theme
-rw-r--r--  1 adamhuan  staff   684 12 25 23:23 re5et.zsh-theme
-rw-r--r--  1 adamhuan  staff  3331 12 25 23:23 refined.zsh-theme
-rw-r--r--  1 adamhuan  staff   268 12 25 23:23 rgm.zsh-theme
-rw-r--r--  1 adamhuan  staff   311 12 25 23:23 risto.zsh-theme
-rw-r--r--  1 adamhuan  staff   789 12 25 23:23 rixius.zsh-theme
-rw-r--r--  1 adamhuan  staff  1870 12 25 23:23 rkj-repos.zsh-theme
-rw-r--r--  1 adamhuan  staff   557 12 25 23:23 rkj.zsh-theme
-rw-r--r--  1 adamhuan  staff   344 12 25 23:23 robbyrussell.zsh-theme
-rw-r--r--  1 adamhuan  staff   191 12 25 23:23 sammy.zsh-theme
-rw-r--r--  1 adamhuan  staff  2492 12 25 23:23 simonoff.zsh-theme
-rw-r--r--  1 adamhuan  staff   230 12 25 23:23 simple.zsh-theme
-rw-r--r--  1 adamhuan  staff   325 12 25 23:23 skaro.zsh-theme
-rw-r--r--  1 adamhuan  staff  3312 12 25 23:23 smt.zsh-theme
-rw-r--r--  1 adamhuan  staff  1318 12 25 23:23 sonicradish.zsh-theme
-rw-r--r--  1 adamhuan  staff  1504 12 25 23:23 sorin.zsh-theme
-rw-r--r--  1 adamhuan  staff   589 12 25 23:23 sporty_256.zsh-theme
-rw-r--r--  1 adamhuan  staff  2816 12 25 23:23 steeef.zsh-theme
-rw-r--r--  1 adamhuan  staff   918 12 25 23:23 strug.zsh-theme
-rw-r--r--  1 adamhuan  staff   748 12 25 23:23 sunaku.zsh-theme
-rw-r--r--  1 adamhuan  staff  2892 12 25 23:23 sunrise.zsh-theme
-rw-r--r--  1 adamhuan  staff   734 12 25 23:23 superjarin.zsh-theme
-rw-r--r--  1 adamhuan  staff   661 12 25 23:23 suvash.zsh-theme
-rw-r--r--  1 adamhuan  staff   788 12 25 23:23 takashiyoshida.zsh-theme
-rw-r--r--  1 adamhuan  staff   356 12 25 23:23 terminalparty.zsh-theme
-rw-r--r--  1 adamhuan  staff   579 12 25 23:23 theunraveler.zsh-theme
-rw-r--r--  1 adamhuan  staff   516 12 25 23:23 tjkirch.zsh-theme
-rw-r--r--  1 adamhuan  staff   514 12 25 23:23 tjkirch_mod.zsh-theme
-rw-r--r--  1 adamhuan  staff  1214 12 25 23:23 tonotdo.zsh-theme
-rw-r--r--  1 adamhuan  staff  3670 12 25 23:23 trapd00r.zsh-theme
-rw-r--r--  1 adamhuan  staff  4479 12 25 23:23 wedisagree.zsh-theme
-rw-r--r--  1 adamhuan  staff   443 12 25 23:23 wezm+.zsh-theme
-rw-r--r--  1 adamhuan  staff   366 12 25 23:23 wezm.zsh-theme
-rw-r--r--  1 adamhuan  staff   333 12 25 23:23 wuffers.zsh-theme
-rw-r--r--  1 adamhuan  staff   574 12 25 23:23 xiong-chiamiov-plus.zsh-theme
-rw-r--r--  1 adamhuan  staff   554 12 25 23:23 xiong-chiamiov.zsh-theme
-rw-r--r--  1 adamhuan  staff  2127 12 25 23:23 ys.zsh-theme
-rw-r--r--  1 adamhuan  staff   686 12 25 23:23 zhann.zsh-theme
.oh-my-zsh [master]

而更多的主题,可以从以下官方网站下载:
https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes

如果需要的主题不在其中,可以从下图标记的【source】中下载:

还可以设置随机主题:

ZSH_THEME_RANDOM_CANDIDATES=(
  "robbyrussell"
  "agnoster"
)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

隐藏
变装