Mac下使用終端的時候需要方便的使用命令提示棵介。
步驟
1.創(chuàng)建文件
touch ~/.bash_profile
touch ~/.git-completion.bash
touch ~/.git-prompt.sh
2.填寫 git-completion.bash 內(nèi)容陷谱,并添加文件的執(zhí)行權限
[https://github.com/git/git/blob/master/contrib/completion/git-completion.bash]
chmod 755 ~/.git-completion.bash
3.填寫 git-prompt.sh 內(nèi)容岖瑰,并添加文件的執(zhí)行權限
[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