美文网首页
mac下的git命令提示

mac下的git命令提示

作者: wuliJJ | 来源:发表于2016-08-23 15:07 被阅读760次

Mac下使用终端的时候需要方便的使用命令提示。

步骤

1.创建文件
touch ~/.bash_profile
touch ~/.git-completion.bash
touch ~/.git-prompt.sh
2.填写 git-completion.bash 内容,并添加文件的执行权限
[https://github.com/git/git/blob/master/contrib/completion/git-completion.bash]
chmod 755 ~/.git-completion.bash
3.填写 git-prompt.sh 内容,并添加文件的执行权限
[https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh]
chmod 755 ~/.git-prompt.sh
4.填写 bash_profile

#!/bin/bash
source ~/.git-completion.bash
source ~/.git-prompt.sh
 
MAGENTA="\[\033[0;35m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[34m\]"
LIGHT_GRAY="\[\033[0;37m\]"
CYAN="\[\033[0;36m\]"
GREEN="\[\033[0;32m\]"
GIT_PS1_SHOWDIRTYSTATE=true
export LS_OPTIONS='--color=auto'
export CLICOLOR='Yes'
export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD
 
export PS1=$LIGHT_GRAY"\u@\h"'$(
    **if** [[ $(__git_ps1) =~ \*\)$ ]]
    # a file has been modified but not added
    **then** echo "'$YELLOW'"$(__git_ps1 " (%s)")
    **elif** [[ $(__git_ps1) =~ \+\)$ ]]
    # a file has been added, but not commited
    **then** echo "'$MAGENTA'"$(__git_ps1 " (%s)")
    # the state is clean, changes are commited
    **else** echo "'$CYAN'"$(__git_ps1 " (%s)")
    **fi**)'$BLUE" \w"$GREEN": "
 
alias ll='ls -lah'
alias gg='git status -s'

5.重启 terminal

参考地址:http://neverstopbuilding.com/gitpro

相关文章

网友评论

      本文标题:mac下的git命令提示

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