终端神器oh-my-zsh安装及配置


不知oh-my-zsh前,虽然知道zsh,但是我大bash超级好用啊.自从用上了oh-my-zsh,见到默认的终端shell,都想先换上zsh再说.


钟情oh-my-zsh的原因

  • 上翻查找命令
  • ctrl+r快速搜索
  • 智能补全(不区分大小写)
  • git插件

安装
oh-my-zsh依懒zsh和git已经安装,请提前自行确认

#检查本机zsh存在
$ grep zsh /etc/shells
/bin/zsh
/usr/bin/zsh
#检查本机git是否安装
$ git --version
git version 2.17.1
#下面开始安装oh-my-zsh
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Cloning Oh My Zsh...
Cloning into '/home/rainbird/.oh-my-zsh'...
remote: Enumerating objects: 1140, done.
remote: Counting objects: 100% (1140/1140), done.
remote: Compressing objects: 100% (1105/1105), done.
remote: Total 1140 (delta 22), reused 903 (delta 17), pack-reused 0
Receiving objects: 100% (1140/1140), 753.58 KiB | 3.41 MiB/s, done.
Resolving deltas: 100% (22/22), done.

Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc.

提示是否将当前shell修改成zsh,当然是Y了

Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] Y
Changing the shell...
Password:
Shell successfully changed to '/usr/bin/zsh'.

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/                       ....is now installed!

Please look over the ~/.zshrc file to select plugins, themes, and options.

p.s. Follow us on https://twitter.com/ohmyzsh

p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh

验证

#检查当前SHELL
➜  ~ echo $SHELL
/usr/bin/zsh
#zsh的配置文件是 .zshrc,通过grep查看启用了哪些配置
➜  ~ egrep -v '^#|^$' ~/.zshrc
export ZSH="/home/rainbird/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh

主题是:robbyrussell oh-my-zsh有多种主题可选,请自行折腾
plugins是当前启用的插件,现在只启用了git

修改终端提示符

export PROMPT='%{$fg_bold[red]%}%n% @%M% %{$fg_bold[green]%} %p%{$fg[cyan]%}%d %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}%{$reset_color%}>'

禁用oh-my-zsh自动检查更新

DISABLE_AUTO_UPDATE="true"

一些使用技巧,参见上面的视频吧

git插件常用命令

alias gss='git status -s'
alias gf='git fetch'
alias gl='git pull'
alias gp='git push'
alias gb='git branch'
alias gcam='git commit -a -m'
alias gcb='git checkout -b'

以上是我常用的,更多命令请自行查看
~/.oh-my-zsh/plugins/git/git.plugin.zsh


相关博文

About rainbird

IOS攻城狮
This entry was posted in linux, Mac and tagged , , , , , . Bookmark the permalink.

发表评论