有一个不辣眼睛、便捷的终端很重要!
拿到一台新的Mac,按如下顺序操作。
Homebrew
推荐。国内安装首选镜像源,极速安装且环境变量自动配置完成。
# 镜像源安装
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
# 安装后配置镜像源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
brew update
国外安装直接用官方的。
# https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
iTerm2
推荐。直接google搜,下载安装包双击运行。
或者brew cask。brew是下载源码解压然后./configure && make install, 并且会自动配置好环境变量。brew cask主要用于有GUI的软件,下载已经编译好的应用包(.dmg/.pkg)。
# 安装cask
brew install caskroom/cask/brew-cask
brew cask install iterm2
oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 切换默认shell为zsh
chsh -s /bin/zsh
主题dracula
zsh主题配置
# download
git clone https://github.com/dracula/zsh.git
# Move dracula.zsh-theme file to oh-my-zsh's theme folder: oh-my-zsh/themes/dracula.zsh-theme.
cp $DRACULA_PATH/dracula.zsh-theme ~/.oh-my-zsh/themes/dracula.zsh-theme
# Move /lib to oh-my-zsh's theme folder: oh-my-zsh/themes/lib.
cp -r $DRACULA_PATH/lib ~/.oh-my-zsh/themes/lib
# Go to your `~/.zshrc` file and set `ZSH_THEME="dracula"`.
# '/ZSH_THEME'查找一下字符串,然后修改配置。!wq保存退出
vim ~/.zshrc
iTerm2主题配置
# download
git clone https://github.com/dracula/iterm.git
设置主题:
- iTerm2 > Preferences > Profiles > Colors Tab
- Open the
Color Presets
… drop-down in the bottom right corner - Select
Import
… from the list - Select the
Dracula.itermcolors
file - Select the
Dracula
from Color Presets…
vim主题语法高亮
# 打开或新建vim配置文件
vim ~/.vimrc
# 添加语法高亮命令,保存退出:wq
syntax on
这样以后用vim就不辣眼睛了,效果图如下
命令行插件
命令行高亮插件
zsh-syntax-highlighting,命令正确绿色,命令错误红色。
# 下载
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# 配置到配置文件~/.zshrc
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
小坑
Note the
source
command must be at the end of~/.zshrc
.
命令提示插件
zsh-autosuggestions,根据历史提示命令行输入,作用有限。
# 下载到~/.zsh/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
# 编辑配置文件
vim ~/.zshrc
# 在末尾添加如下命令
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
重启生效
更多:iterm2, oh-my-zsh官方文档
评论区