1. 打開 gitbash
2. 將以下文件備份&置空
cd /etc
mkdir bak&mv bash.bashrc profile bak
3. 添加自己的環(huán)境變量
vim /etc/profile
# 目錄添加顏色
profile_d ()
{
for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
[ -e "${file}" ] && . "${file}"
done
}
profile_d sh
### 環(huán)境變量配置
export PATH=$PATH:'/d/AppData/JetBrains/IntelliJ IDEA 2018.1.3/plugins/maven/lib/maven3/bin'
4. 分析原因
主要是執(zhí)行git命令時間較長淳蔼,當打開終端時會獲取當前倉庫的分支名
更改終端展示樣式行首展示樣式
- 修改 bash.bashrc 文件內(nèi)容
echo /etc/profile.d/git-prompt.sh>/etc/bash.bashrc
- 修改 git-prompt.sh 文件內(nèi)容
cp /etc/profile.d/git-prompt.sh /etc/profile.d/git-prompt.sh.bak
vim /etc/profile.d/git-prompt.sh
PS1='' # set window title
# PS1="$PS1"'\n' # new line
# PS1="$PS1"'\[\033[35m\]' # change to purple
# PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1"'\[\033[34m\]' # change to brownish blue
PS1="$PS1"'\w' # current working directory
### 下邊是展示分支的邏輯,執(zhí)行需 2s 時長
#if test -z "$WINELOADERNOEXEC"
#then
# GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
# COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
# COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
# if test -f "$COMPLETION_PATH/git-prompt.sh"
# then
# . "$COMPLETION_PATH/git-prompt.sh"
# PS1="$PS1"'\[\033[36m\]' # change color to cyan
# PS1="$PS1"'`__git_ps1`' # bash function
# fi
#fi
PS1="$PS1"'\[\033[32m\]' # change to green
PS1="$PS1"':) ' # prompt: always $
PS1="$PS1"'\[\033[0m\]' # change color