zl程序教程

您现在的位置是:首页 >  其他

当前栏目

程序员手上的效率神奇——简单安装非常有效率的Terminal终端

效率安装程序员 简单 终端 非常 神奇 terminal
2023-09-11 14:22:08 时间

程序员手上的效率神奇——简单安装非常有效率的Terminal终端。

iTerm 2 能成为程序员口中的神器得益于它比自带终端拥有更强大的可定制化功能,如分屏、多个 Remote 一键自动登录、 命令广播到所有终端等等,配合上 Oh My Zsh 更是锦上添花,Oh My Zsh 是 Zsh Shell 中的插件工具集。

让 Zsh 火起来的就是这个 Oh My Zsh,丰富的插件生态、简便的配置方法,好看的主题让 Oh My Zsh 真正成为程序员手上的效率神器,想让自己变得更有效率,可以试试 iTerm2 + Oh My Zsh。

完成效率神器搭建需要安装或者准备这些东西:

Brew,Mac 安装工具,系统默认
iTerm 2
Zsh
Oh My Zsh
主题:spaceship
字体: Sauce Code Pro Nerd Font
插件列表(插件不在多,够用就好):
Git,一般都会自带
AutoJump
zsh-syntax-highlighting
zsh-autosuggestions

安装 iTerm 2
官网下载地址:https://iterm2.com/downloads.html

安装 Zsh
brew install zsh
将 Zsh 替换成系统默认 Shell
sudo -s 'echo /usr/local/bin/zsh >> /etc/shells' && chsh -s /usr/local/bin/zsh

安装 Oh My Zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
安装 Oh My Zsh 主题 spaceship
克隆主题下来:

git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
将克隆下来的主题软连接到 zsh 的主题文件夹中

ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
修改~/.zshrc中的主题名
ZSH_THEME="spaceship"
在命令行输入source ~/.zshrc 让zshrc生效。

安装 Sauce Code Pro Nerd Font 字体
先執行這行,才能用 homebrew 安裝字型。曾經執行過的人可以跳過這個指令:

brew tap caskroom/fonts
安装字体

brew cask install font-sourcecodepro-nerd-font
安装好之后设置 iTerm 2 -> Preferences -> Profiles -> Text -> Change Font 选择刚才安装的 sourcecodepro-nerd-font 字体

安装各种插件
AutoJump
根据历史的访问记录快速访问目标目录

命令行安装:

brew install autojump
将 autojump 放入~/.zshrc中的插件设置中:

plugins=(git autojump)~/.zshrc的结尾添加:

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
最后在命令行输入source ~/.zshrc 让zshrc生效。

zsh-syntax-highlighting
命令语法高亮插件,错的命令显示红色,对的命令显示绿色

克隆项目到 Oh My Zsh 的插件文件夹里面:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

将 zsh-syntax-highlighting 放入~/.zshrc中的插件设置中:

plugins=(git autojump zsh-syntax-highlighting)
在命令行输入source ~/.zshrc 让zshrc生效。

zsh-autosuggestions
命令补全插件,会显示出你用过的命令

克隆项目到 Oh My Zsh 的插件文件夹里面:

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
将 zsh-autosuggestions 放入~/.zshrc中的插件设置中:

plugins=(git autojump zsh-syntax-highlighting zsh-autosuggestions)
在命令行输入source ~/.zshrc 让zshrc生效。

其他好用的插件得靠自己了。