ZSH 使用教程

作者: 疯狂的冰块 | 来源:发表于2017-12-15 13:57 被阅读146次

    zsh被誉为shell中的极品,自然有他的道理。下面我们总结一下zsh常见的用法。

    1、安装zsh 和oh my zsh

    sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    

    2、git 自动显示当前分支名称和修改状态


    image.png

    3、git 快捷键
    zsh帮我们配置了一些git的常常用命令简写,我常用的是几个命令

    gst 代表git status
    gca 代表 git commit -v -a'
    gco 代表git checkout
    

    一下是git的部分配置:

    alias g='git'
    
    alias ga='git add'
    alias gaa='git add --all'
    alias gapa='git add --patch'
    alias gau='git add --update'
    alias gap='git apply'
    
    alias gb='git branch'
    alias gba='git branch -a'
    alias gbd='git branch -d'
    alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
    alias gbl='git blame -b -w'
    alias gbnm='git branch --no-merged'
    alias gbr='git branch --remote'
    alias gbs='git bisect'
    alias gbsb='git bisect bad'
    alias gbsg='git bisect good'
    alias gbsr='git bisect reset'
    alias gbss='git bisect start'
    
    alias gc='git commit -v'
    alias gc!='git commit -v --amend'
    alias gcn!='git commit -v --no-edit --amend'
    alias gca='git commit -v -a'
    alias gca!='git commit -v -a --amend'
    alias gcan!='git commit -v -a --no-edit --amend'
    alias gcans!='git commit -v -a -s --no-edit --amend'
    alias gcam='git commit -a -m'
    alias gcsm='git commit -s -m'
    alias gcb='git checkout -b'
    alias gcf='git config --list'
    alias gcl='git clone --recursive'
    alias gclean='git clean -fd'
    alias gpristine='git reset --hard && git clean -dfx'
    alias gcm='git checkout master'
    alias gcd='git checkout develop'
    alias gcmsg='git commit -m'
    alias gco='git checkout'
    alias gcount='git shortlog -sn'
    compdef _git gcount
    alias gcp='git cherry-pick'
    alias gcpa='git cherry-pick --abort'
    alias gcpc='git cherry-pick --continue'
    alias gcs='git commit -S'
    

    详情参见:
    https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh

    相关文章

      网友评论

        本文标题:ZSH 使用教程

        本文链接:https://www.haomeiwen.com/subject/zixdwxtx.html