mac终端利器 iterm2主题配置

617 阅读1分钟

下载iterm2

1.iterm2.com/下载

2.下载完成后双击解压即可

Zsh是什么

Zsh 是一款强大的虚拟终端,既是一个系统的虚拟终端,也可以作为一个脚本语言的交互解析器

打开终端,在终端上输入: 
zsh --version
这个命令来查看我们的电脑上是否安装了 Zsh 
1.如果没有安装zsh,需要先进行安装
sudo apt-get install zsh
2.替换默认用户shell
chsh -s /bin/zsh

安装zsh扩展工具oh-my-zsh

wget 安装

sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

安装过程中可能会提示失败拒绝连接问题 怎样解决?

1.查询IP,去这里site.ip138.com/ ,输入raw.githubusercontent.com 进行查询:

2.修改hosts文件,mac如何修改hosts,可以自行百度,将151.101.76.133 raw.githubusercontent.com加入到hosts中,再安装oh-my-zsh

下载主题powerlevel9k

下载主题,并将主题直接下载到iterm2主题库下

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

设置主题

安装完毕后,我们就可以使用了,先来简单配置一下,Oh My Zsh 提供了很多主题风格,我们可以根据自己的喜好,设置主题风格

open ~/.zshrc
# 找到 ZSH_THEME
ZSH_THEME="powerlevel9k/powerlevel9k"
重启终端,或者source ~/.zshrc重新加载.zshrc文件
主题设置成功

下载主题需要的字体

此时打开终端会出现乱码,需要下载字体

brew tap homebrew/cask-fonts
brew cask install font-hack-nerd-font

配置item2字体

选择 iterm2下preferences>Profiles>Text, 字体大小设置一致

如何打开iterm2下preferences,可以通过快捷键command+,

隐藏用户名

默认终端前面会展示用户名,例如某某demacbookpro,如何不想展示用户名,

open ~/.zshrc
在合适到地方添加DEFAULT_USER=$USER

效果图

安装oh my zsh后出现的目录权限问题

运行终端,可能会冒出下面一大堆提示

[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxrwx 3 chenzhuo admin 96 6 29 23:39 /usr/local/share/zsh
drwxrwxrwx 7 chenzhuo admin 224 7 1 18:38 /usr/local/share/zsh/site-functions

[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of “group” and “others” and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn’t help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] “true” before oh-my-zsh is sourced in your zshrc file.

解决: 改变目录的权限

chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions