This is the Z Shell configuration function for new users, zsh-newuser-install. You are seeing this message because you have no zsh startup files (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory ~). This function can help you with a few settings that should make your use of the shell easier.
You can:
(q) Quit and do nothing. The function will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again.
(1) Continue to the main menu.
(2) Populate your ~/.zshrc with the configuration recommended by the system administrator and exit (you will need to edit the file by hand, if so desired).
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" # 或者 sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
安装成功提示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Looking for an existing zsh config... Found /home/vvd/.zshrc. Backing up to /home/vvd/.zshrc.pre-oh-my-zsh Using the Oh My Zsh template file and adding it to /home/vvd/.zshrc.
alias ga='git add' alias gaa='git add --all' alias gapa='git add --patch' alias gau='git add --update' alias gav='git add --verbose' alias gap='git apply' alias gapt='git apply --3way'
......
自定义别名,在 ~/.zshrc 中,最下面直接写即可。
1 2
# Example aliases alias ll='ls -lahF --color--time-style=long-iso'
# 状态与提交 alias gs='git status -sb' alias ga='git add' alias gaa='git add --all' alias gc='git commit' alias gcm='git commit -m' alias gca='git commit --amend' alias gcan='git commit --amend --no-edit'
# 分支操作 alias gb='git branch' alias gco='git checkout' alias gcb='git checkout -b' alias gbd='git branch -d'
# 日志与对比 alias gl='git log --oneline --graph --decorate' alias gd='git diff' alias gdc='git diff --cached'
# 一键提交所有修改 alias gac='git add --all && git commit -m'
# 强制推送当前分支 alias gpf='git push --force-with-lease'
# 拉取并切换远程分支 alias gcor='git fetch && git checkout'
z 是一个文件夹快捷跳转插件,对于曾经跳转过的目录,只需要输入最终目标文件夹名称,就可以快速跳转,避免再输入长串路径,提高切换文件夹的效率。
安装步骤:
由于 oh-my-zsh 内置了 z 插件,所以只需要在 .zshrc 中,把 z 加入插件列表:
1 2 3 4 5 6
plugins=( # other plugins... zsh-autosuggestions zsh-syntax-highlighting z )
开启新的 Shell 或执行 source ~/.zshrc,就可以开始体验插件了。
升级 Oh My Zsh
打开终端输入:
1
upgrade_oh_my_zsh
卸载 Oh My Zsh
终端输入 :
1 2
uninstall_oh_my_zsh Are you sure you want to remove Oh My Zsh? [y/N] Y
终端提示信息:
1 2 3 4 5 6
Removing ~/.oh-my-zsh Looking for original zsh config... Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc Found ~/.zshrc -- Renaming to ~/.zshrc.omz-uninstalled-20170820200007 Your original zsh config was restored. Please restart your session. Thanks for trying out Oh My Zsh. It's been uninstalled.