最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中升级效果更好的on-my-zsh和自动补全

Mac crifan 766浏览 0评论
自己的Mac之前已安装过zsh,然后在iTerm2中,用着还凑合。
但是不够好,没有之前给公司Mac安装的好用。
此处:tab时,都无法列出来所有选项,而是直接匹配了其中某个,且不是我们希望的。
以及保留上次和最近的输入命令,没法通过箭头匹配出完整的命令。
-》后来才知道是:zsh的插件,叫做zsh-autosuggestion 起的效果
参考之前的:
【已解决】mac的iterm2安装oh-my-zsh
去重新安装一遍。
改主题
ZSH_THEME="af-magic"
为:
➜  ~ cat ~/.zshrc | grep THEME
#ZSH_THEME="robbyrussell"
ZSH_THEME="af-magic"
新开的iTerm2终端就能看到新主题的效果了:
右边显示当前用户
先确认pip版本:
~ » which pip                                                                                                                 
pip: aliased to noglob pip
------------------------------------------------------------
~ » pip --version                                                                                                             [email protected]
pip 20.0.2 from /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip (python 3.7)
再去:
~ » pip show powerline-status                                                                                                 [email protected]
Name: powerline-status
Version: 2.7
Summary: The ultimate statusline/prompt utility.
Home-page: https://github.com/powerline/powerline
Author: Kim Silkebaekken
Author-email: [email protected]
License: MIT
Location: /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages
Requires:
Required-by:
安装字体
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts 
./install.sh
过程日志:
➜  ~ cd Downloads
➜  Downloads git clone https://github.com/powerline/fonts.git --depth=1
Cloning into 'fonts'...
remote: Enumerating objects: 310, done.
remote: Counting objects: 100% (310/310), done.
remote: Compressing objects: 100% (236/236), done.
remote: Total 310 (delta 75), reused 260 (delta 71), pack-reused 0
Receiving objects: 100% (310/310), 10.40 MiB | 101.00 KiB/s, done.
Resolving deltas: 100% (75/75), done.
➜  Downloads cd fonts
➜  fonts git:(master) ./install.sh
Copying fonts...
Resetting font cache, this may take a moment...
Powerline fonts installed to /Users/crifan/Library/Fonts
去iTerm2中设置字体
Meslo LG S DZ for Powerline
git clone https://github.com/altercation/solarized
cd solarized/iterm2-colors-solarized/
open .
Colors Scheme Imported
The color scheme was imported and added to presets. You can find it under Preferences>Profiles>Colors>Load Presets….
再去iTerm2中设置Colors:
为Solarized Dark
效果是:
不过感觉还是没有之前的:
Tango Dark 好看
再去安装主题
git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git 
cd oh-my-zsh-agnoster-fcamblor/ 
./install
log
➜  Downloads git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
Cloning into 'oh-my-zsh-agnoster-fcamblor'...
remote: Enumerating objects: 136, done.
^Cceiving objects:  37% (51/136), 260.01 KiB | 31.00 KiB/s
➜  Downloads git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
➜  Downloads git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
Cloning into 'oh-my-zsh-agnoster-fcamblor'...
remote: Enumerating objects: 136, done.
remote: Total 136 (delta 0), reused 0 (delta 0), pack-reused 136
Receiving objects: 100% (136/136), 1.14 MiB | 963.00 KiB/s, done.
Resolving deltas: 100% (59/59), done.
➜  Downloads cd oh-my-zsh-agnoster-fcamblor/
➜  oh-my-zsh-agnoster-fcamblor git:(master) ./install
Creating symlink from here to your oh-my-zsh themes path...


Done ! (the symlink is ~/.oh-my-zsh/themes/agnoster-fcamblor.zsh-theme)


----------------------------------------------------------------------------------


Options:
All options must be overridden in your .zshrc file.
See README.md for more info.


----------------------------------------------------------------------------------


Requirements:
Vim Powerline patched font: See Powerline for vim for more info.
Z shell (zsh): See oh-my-zsh for more info.
Make sure terminal is using 256-colors mode with export TERM="xterm-256color".
把主题改为agnoster:
➜  oh-my-zsh-agnoster-fcamblor git:(master) cat ~/.zshrc| grep THEME
#ZSH_THEME="robbyrussell"
#ZSH_THEME="af-magic"
ZSH_THEME="agnoster"
立刻生效方式:
  • 重启iTerm2
    • Command+Q退出再重新打开iTerm2
  • source
    • source ~/.zshrc
效果:
再去安装高亮插件:
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
vi ~/.zshrc
本身已有:
plugins=(git osx brew python pip virtualenv  docker github gitignore gnu-utils svn yum debian systemd terminalapp pod)
去加上zsh-syntax-highlighting
 [email protected]  ~/.oh-my-zsh/custom/plugins   master  cat ~/.zshrc| grep plugins
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git osx brew python pip virtualenv  docker github gitignore gnu-utils svn yum debian systemd terminalapp pod zsh-syntax-highlighting)
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
再去生效:
source ~/.zshrc
可见 ls和ll都高亮了:
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/.zshrc
log
 [email protected]  ~/.oh-my-zsh/custom/plugins   master  git clone https://github.com/zsh-users/zsh-autosuggestions
Cloning into 'zsh-autosuggestions'...
remote: Enumerating objects: 2385, done.
remote: Total 2385 (delta 0), reused 0 (delta 0), pack-reused 2385
Receiving objects: 100% (2385/2385), 541.32 KiB | 775.00 KiB/s, done.
Resolving deltas: 100% (1531/1531), done.
加上:
xxx  ~/.oh-my-zsh/custom/plugins   master  cat ~/.zshrc |grep plugins
...
plugins=(git osx brew python pip virtualenv  docker github gitignore gnu-utils svn yum debian systemd terminalapp pod zsh-autosuggestions zsh-syntax-highlighting)
...
生效后,输入了一部分后,立刻自动匹配,之前的,历史命令:
效果很爽-》经常用,能省很多时间。
另外颜色最后还是去换:
Solarized Dark
感觉稍微柔和些。是不错。
【总结】
参考:
iTerm2 + Oh My Zsh 打造舒适终端体验 – 个人文章 – SegmentFault 思否
或之前自己的:
【已解决】mac的iterm2安装oh-my-zsh
最终效果很不错:
其中,最实用的,感觉是:zsh-autosuggestions
-》自动匹配完成历史命令的感觉,太爽了。

转载请注明:在路上 » 【已解决】Mac中升级效果更好的on-my-zsh和自动补全

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
86 queries in 0.114 seconds, using 20.52MB memory