简介
对于程序猿来说,你或多或少地都会接触到命令行,甚至很多程序员只在终端下就能完成大部分工作,所以一个易用又漂亮的终端配置教程来了。
iTerm2
安装
iTeram2:《官网》。
brew install iterm2
配色
官网:《GitHub》、《Solarized Dark Higher Contrast》。
安装:将配色方案的内容复制并保存为本地文件(SolarizedDarkHigherContrast.itermcolors),然后双击安装。
设置:iTerm2 ==> Preferences ==> Profiles ==> Colors ==> Colors Presets ==> SolarizedDarkHigherContrast。
透明度
设置:
iTerm2 ==> Preferences ==> Profiles ==> Window ==> Transparency ==> 15。iTerm2 ==> Preferences ==> Profiles ==> Window ==> Transparency ==> Keep backaground colors opaque。字体
官网:《链接》。brew tap homebrew/cask-fontsbrew install --cask font-hack-nerd-font
设置:
iTerm2 ==> Preferences ==> Profiles ==> Text ==> Font ==> Hack Nerd Font MonoiTerm2 ==> Preferences ==> Profiles ==> Text ==> Font ==> RegulariTerm2 ==> Preferences ==> Profiles ==> Text ==> Font ==> 14背景图片
设置:iTerm2 ==> Preferences ==> Profiles ==> Window ==> Background Image ==> Enabled,选择自己喜欢的背景图即可。
推荐背景图:《地图》、《鬼刀》。回滚缓冲区
回滚缓冲区:无限缓冲区,防止执行命令的输出过多,导致无法查询执行结果。
设置:iTerm2 ==> Preferences ==> Profiles ==> Terminal ==> Scrollback Buffer ==> Unlimited scrollback。克隆会话
避免重复输入登录堡垒机的口令:iTerm2 ==> Preferences ==> General ==> Working Directory ==> Reuse previous sessions’s directory。
配置SSH:
```properties Host * User root Port 22 ControlMaster auto ControlPath ~/.ssh/%C ServerAliveInterval 60 ServerAliveCountMax 10 StrictHostKeyChecking no UserKnownHostsFile /dev/nullmkdir -p ~/.sshvim ~/.ssh/config
Host XBlog Hostname xiaocoder.com
Host XK8S Hostname 47.108.28.233
Host SS Hostname 139.198.121.164
Host agumon.com Hostname github.com User git IdentityFile ~/.ssh/agumon_id_rsa
<a name="d24a4395"></a>### 凿壁偷光```bash# 需要客户端export all_proxy="socks5://127.0.0.1:1086"
curl https://api.myip.com
unset all_proxy
OhMyZsh
安装
MacOS一般自带了Zsh,无需额外安装,修改默认的Shell为Zsh。
chsh -s /bin/zsh
OhMyZsh:轻松配置Zsh,快速提高工作效率。
# GitHubsh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Gitee 推荐国内用户使用sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
主题
官网:《链接》。
克隆主题仓库到OhMyZsh的用户自定义主题目录中:
# GitHubgit clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
# Gitee 推荐国内用户使用git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
设置变量后,需重启终端:
sed -i "" 's@^ZSH_THEME=.*@ZSH_THEME="powerlevel10k/powerlevel10k"@g' ~/.zshrc
配置主题:
# 在终端执行交互式命令进行配置p10k configure# Install Meslo Nerd Font?(下载字体):No# Does this look like a diamond (rotated square)?(钻石图标):Yes# Does this look like a lock?(锁图标):Yes# Does this look like a Debian logo (swirl/spiral)?(Debian Logo):Yes# Do all these icons fit between the crosses?:Yes# Prompt Style(提示样式):Rainbow# Character Set(字符集):Unicode# Show current time?(显示当前时间):24-hour format# Prompt Separators(提示分隔符):Angled# Prompt Heads(提示头部):Sharp# Prompt Tails(提示尾部): Blurred# Prompt Height(提示高度):One line# Prompt Spacing(提示间距):Compact# Icons(图标):Many icons# Prompt Flow(提示流): Concise# Enable Transient Prompt(瞬时提示): No# Instant Prompt Mode(即时提醒):Verbose# 是否覆盖已存在的配置文件:Yes# 是否应用配置文件:Yes
插件
设置~/.zshrc中的变量:
plugins=(gitcolored-man-pagescolorizegithubbrewmacosautojumpzsh-autosuggestionszsh-syntax-highlighting)
autojump:可以用于直达常用目录。
brew install autojump
zsh-autosuggestions:补全历史输入的命令,用方向键->即可补全。
# GitHubgit clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions# Gitee 推荐国内用户使用git clone https://gitee.com/pocmon/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
zsh-syntax-highlighting:语法高亮显示。
# GitHubgit clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting# Gitee 推荐国内用户使用git clone https://gitee.com/lightnear/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
