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