47

Mac 用户如何打造史上最强终端

 6 years ago
source link: http://mp.weixin.qq.com/s/tWrxxrRyKAGohJfq8LUAGQ?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Mac用户如何打造史上最强终端

Original 许江 whoami 2018-01-06 10:30 Posted on

捣鼓一下,Mac下的终端主题,最开始我选择的是on-my-zsh,非常强大,用起来基本停不下来。

通过oh-my-zsh提供的External-themes列表,支持多种漂亮的UI。

我选择的是powerlevel9k,安装还挺复杂,接下来我介绍一下。

Image

安装powerlevel9k

powerlevel9k安装方式如下:

  • 安装powerlevel9k

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

你需要修改~/.zshrc中的ZSH_THEME="powerlevel9k/powerlevel9k",重新运行终端iTerm2,如果出现乱码框,你需要通过 iTerm2 > Preferences > Profile > Text ;修改终端字体和Non-ASCII字体为Roboto Mono for Powerline

  • 安装powerline-fonts

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

炫酷主题地址

  • 安装SourceCodePro字体

brew tap caskroom/fonts && brew cask install font-source-code-pro
  • 安装Awesome Regular 12字体

克隆字体成功后,进入build目录,点击字体进行安装。

git clone [email protected]:gabrielelana/awesome-terminal-fonts.git

安装成功如下:

Image

详情访问:https://github.com/gabrielelana/awesome-terminal-fonts/wiki/OS-X

系统可加载字体,需要如下操作,必须先通过csrutil命令disable,可修改系统保护文件。

重启按住command + R 键进入recovery模式,打开终端,才能执行,执行效果如下,重启验证机器。

关闭SIP
csrutil disable; reboot
Image
验证SIP Status
Image
复制默认字体文件
cp /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist ~/Desktop
修改字体文件通过Xcode,并且备份默认字体文件
open -a Xcode.app ~/Desktop/DefaultFontFallbacks.plist

cp /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist ~/DefaultFontFallbacks.plist.bak
移动改过的字体文件覆盖,系统默认的字体文件
sudo mv ~/Desktop/DefaultFontFallbacks.plist /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist
恢复csrutil为enable模式

需要重复之前操作,把系统进入recovery模式,否则执行命令报错

csrutil: failed to modify system integrity configuration. This tool needs to be executed from the Recovery OS.

进入recovery模式执行

csrutil enable; reboot

需要突破系统一些限制,所以稍微有点繁琐。

附上我的~/.zshrc配置

POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true

POWERLEVEL9K_MODE='awesome-patched'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status nvm node_version)

POWERLEVEL9K_OS_ICON_BACKGROUND="white"
POWERLEVEL9K_OS_ICON_FOREGROUND="blue"
POWERLEVEL9K_DIR_HOME_FOREGROUND="white"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="white"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"

废话少说,上效果图。

Image

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK