windows gitbash 打开太慢&终端改造

1. 打开 gitbash

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

mkdir ~/bak&cp /etc/bash.bashrc /etc/profile /etc/profile.d/git-prompt.sh bak

3. 需修改三个文件

文件 1

  • vim /etc/profile
print_flags ()
{
  (( $1 & 0x0002 )) && echo -n "binary" || echo -n "text"
  (( $1 & 0x0010 )) && echo -n ",exec"
  (( $1 & 0x0040 )) && echo -n ",cygexec"
  (( $1 & 0x0100 )) && echo -n ",notexec"
}

# Shell dependent settings
profile_d ()
{
  local file=
  for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
    [ -e "${file}" ] && . "${file}"
  done
  
  if [ -n "${MINGW_MOUNT_POINT}" ]; then
    for file in $(export LC_COLLATE=C; echo ${MINGW_MOUNT_POINT}/etc/profile.d/*.$1); do
      [ -e "${file}" ] && . "${file}"
    done
  fi
}
### 下边配置的环境变量
export PATH=$PATH:~/tools:'/d/Program Files/anaconda3/Scripts':'/d/AppData/JetBrains/IntelliJ IDEA 2018.1.3/plugins/maven/lib/maven3/bin'

文件 2

  • vi /etc/bash.bashrc
# If started from sshd, make sure profile is sourced
if [[ -n "$SSH_CONNECTION" ]] && [[ "$PATH" != *:/usr/bin* ]]; then
    source /etc/profile
fi

shopt -q login_shell || . /etc/profile.d/git-prompt.sh

文件 3 (可以配置展示路径后当前分支)

  • vi /etc/profile.d/git-prompt.sh
if test -f ~/.config/git/git-prompt.sh
then
    . ~/.config/git/git-prompt.sh
else
    PS1='\[\033]0;$PWD\007\]' # set window title
    PS1="$PS1"'\[\033[31m\]'       # change to brownish red
    # PS1="$PS1"'\[\033[35m\]'       # change to brownish purple
    PS1="$PS1"'\w'                 # current working directory
#####   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%/lib/git-core}"
#####       COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
#####       if test -f "$COMPLETION_PATH/git-prompt.sh"
#####       then
#####           . "$COMPLETION_PATH/git-prompt.sh"  # 展示当前目录对应的分支 例如:~ (test-2.1.4):)
#####           PS1="$PS1"'\[\033[36m\]'  # change color to cyan
#####           PS1="$PS1"'`__git_ps1`'   # bash function
#####       fi
#####   fi
    PS1="$PS1"'\[\033[36m\]'        # change color
#   PS1="$PS1"'\n'                 # new line
    PS1="$PS1"':) '                 # prompt: always $
    PS1="$PS1"'\[\033[0m\]'        # change color 输入内容 & 终端输出颜色
fi

MSYS2_PS1="$PS1"               # for detection by MSYS2 SDK's bash.basrc

# Evaluate all user-specific Bash completion scripts (if any)
if test -z "$WINELOADERNOEXEC"
then
    for c in "$HOME"/bash_completion.d/*.bash
    do
        # Handle absence of any scripts (or the folder) gracefully
        test ! -f "$c" ||
        . "$c"
    done
fi

你可能感兴趣的:(windows gitbash 打开太慢&终端改造)