使用 alias
用户目录创建 .bash_profile
文件
alias bashalias='code ~/.bash_profile'
alias bashcolor='code ~/.minttyrc'
alias bashconfig='code /etc/profile.d/git-prompt.sh'
alias gitconfig='code ~/.gitconfig'
alias .='cd ~'
alias ..='cd ..'
alias ...='cd ../..'
alias e='exit'
alias cls='clear'
alias gs='git status'
alias ga='git add .'
alias gc='git commit -m'
alias gp='git push'
alias gitauto='git add . && git commit -m "auto deploy" && git push'
alias gitautoall='git add . && git commit -m "auto deploy" && git push all'
alias sysoff='shutdown -s -t 0'
alias sysre='shutdown -r -t 0'
alias host='code /c/Windows/System32/drivers/etc/hosts'
优化外观
.minttyrc
用户目录下创建 .minttyrc
Font=Source Code Pro
FontHeight=14
Transparency=low
FontSmoothing=default
Locale=C
Charset=UTF-8
Columns=88
Rows=26
OpaqueWhenFocused=no
Scrollbar=none
Language=zh_CN
ForegroundColour=131,148,150
BackgroundColour=0,43,54
CursorColour=220,130,71
BoldBlack=128,128,128
Red=255,64,40
BoldRed=255,128,64
Green=64,200,64
BoldGreen=64,255,64
Yellow=190,190,0
BoldYellow=255,255,64
Blue=0,128,255
BoldBlue=128,160,255
Magenta=211,54,130
BoldMagenta=255,128,255
Cyan=64,190,190
BoldCyan=128,255,255
White=200,200,200
BoldWhite=255,255,255
BellTaskbar=no
Term=xterm
FontWeight=400
FontIsBold=no
git-prompt.sh
vscode 运行 $ code /etc/profile.d/git-prompt.sh
if test -f /etc/profile.d/git-sdk.sh
then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
TITLEPREFIX=$MSYSTEM
fi
if test -f ~/.config/git/git-prompt.sh
then
. ~/.config/git/git-prompt.sh
else
PS1='\[\033]0;Bash\007\]' # 窗口标题
PS1="$PS1"'\n' # 换行
PS1="$PS1"'\[\033[32;1m\]' # 高亮绿色
PS1="$PS1"'➜ ' # unicode 字符,右箭头
PS1="$PS1"'\[\033[33;1m\]' # 高亮黄色
PS1="$PS1"'\W' # 当前目录
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-completion.bash"
. "$COMPLETION_PATH/git-prompt.sh"
PS1="$PS1"'\[\033[31m\]' # 红色
PS1="$PS1"'`__git_ps1`' # git 插件
fi
fi
PS1="$PS1"'\[\033[36m\] ' # 青色
fi
MSYS2_PS1="$PS1"
注意:如果在你的 windows 版本下 git bash 光标错位,你要修改 git-prompt.sh
下的 符号 '➜ ',我建议你将它改为普通字符,即可解决!
参考资料:
为 win10 打造 Linux 终端(非 wsl)