windows gitbash 打开太慢解决办法

1. 打开 gitbash

2. 将以下文件备份&置空

cd /etc
mkdir bak&mv bash.bashrc profile bak

3. 添加自己的环境变量

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

### 环境变量配置
export PATH=$PATH:'/d/AppData/JetBrains/IntelliJ IDEA 2018.1.3/plugins/maven/lib/maven3/bin'

4. 分析原因

主要是执行git命令时间较长,当打开终端时会获取当前仓库的分支名
更改终端展示样式行首展示样式

    1. 修改 bash.bashrc 文件内容
echo /etc/profile.d/git-prompt.sh>/etc/bash.bashrc
    1. 修改 git-prompt.sh 文件内容
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
### 下边是展示分支的逻辑,执行需 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

你可能感兴趣的:(windows gitbash 打开太慢解决办法)