iTerm2 + zsh + oh-my-zsh
你在默认终端纠结吗?希望你的终端看起来像这样吗?默认终端很糟糕?
如果你想让你的终端看起来像上图。来吧,这篇会适合你。
安装Homebrew
打开终端并粘贴。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
下载iTerm2
- 转到下载页面https://www.iterm2.com/downloads.html
- 下载后,将文件拖放到我们的Application文件夹。
安装zsh
打开终端并粘贴。
brew install zsh
我们需要“oh-my-zsh”
Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a few things that make you shout…
--“Oh My ZSH!”
安装oh-my-zsh
安装时,oh-my-zsh将自动用zsh替换默认终端。
打开终端并粘贴。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
使用颜色装饰 iTerm2
- 打开终端并粘贴
$ cd Downloads
$ curl -O https://raw.githubusercontent.com/MartinSeeler/iterm2-material-design/master/material-design-colors.itermcolors
打开已在第一部分下载的 iTerm2
转到 iTerm2 > Preferences > Profiles > Colors
单击右下角的 Color Presets…
单击 Import…
选择
material-design-colors.itermcolors
文件在 Load Presets... 选择 material-design-colors
管理插件
插件维基页面:https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
在这种情况下,我想在我的zsh上启用插件'docker',所以我将运行此命令
vi~ / .zshrc
并键入“/ plugin”(不带引号)按Enter键,键入“i”字符并插入要添加的插件。
.
.
.
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
)
在这种情况下,我将添加docker插件,只需在我们的括号中添加“docker”。
.
.
.
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
docker
)
在您满意后,按Esc
并键入:wq
,这意味着您保存文件并立即退出。并重启iTerm2。
添加别名(永久别名)
vi ~/.zshrc
.
.
.
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias dkps="docker ps"
alias dkst="docker stats"
alias dkpsa="docker ps -a"
alias dkimgs="docker images"
alias dkcpup="docker-compose up -d"
alias dkcpdown="docker-compose down"
alias dkcpstart="docker-compose start"
alias dkcpstop="docker-compose stop"
如果我输入 dkps
,它将执行 docker ps