git终端提示符

最近使用git bash的时候,看到默认的终端提示符不爽,主要是太长了。所以想对git终端提示符进行优化

默认git的终端提示符会是  用户名@设备名称 ,我想改成更短的来查看。

提示符是由一个环境变量定义的,叫做 PS1(是“prompt string one” 的简写)。我们可以通过 echo 命令来查看 PS1的内容:

echo $PS1
[33]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}07] [33[32m]u@h [33[33m]w$(__git_ps1)[33[0m] $

  设置 PS1 变量的文件在windows和mac下位置是不一样的。

windows下位置:

# 假设 git 安装在 C:Program Files目录下
C:Program FilesGitetcprofile

  打开该文件,找到:

PS1="$PS1"'u@h '             # user@host<space>
PS1="$PS1"'[33[33m]'       # change color
PS1="$PS1"'w'                 # current working directory

  改成:

PS1="$PS1"'W'                 # current working Name
PS1="$PS1"'[33[33m]'       # change color
PS1="$PS1"' $'                 # end add <space>$

  

mac下位置:

~/.bash_profile

  

具体设置产考:

http://billie66.github.io/TLCL/book/chap14.html

git教程:

http://git-scm.com/docs

GitForWindows中文乱码问题:

https://github.com/mrljdx/GitForWindows-

mac oh_my_zsh 终端小黄叉提示:

http://foocoder.com/blog/wo-zai-yong-de-macruan-jian-2.html/

其他类似文档:

http://equation85.github.io/blog/customize-terminal-on-mac/

原文地址:https://www.cnblogs.com/ayseeing/p/4478601.html