git terminal prompt

Source: Internet
Author: User

When I recently used Git bash, it was mostly too long to see the default terminal prompt uncomfortable. So you want to optimize the Git terminal prompt

The default Git terminal prompt will be the username @ device name and I want to change it to a shorter one to view.

The prompt is defined by an environment variable, called PS1 (the shorthand for "prompt string One"). We can use the echo command to view the contents of the PS1:

echo $PS 1
\[\033]0; $MSYSTEM: ${pwd//[^[:ascii:]]/?} \007\]\n\[\033[32m\]\[email protected]\h \[\033[33m\]\w$ (__GIT_PS1) \[\033[0m\]\n$

The files that set the PS1 variable are not the same in Windows and Mac locations.

under Windows location:
# assuming Git is installed in the C:\Program files directory
C:\Program Files\git\etc\profile

Open the file to find:

ps1= "$PS 1" ' \[email protected]\h '             # [email protected]<space>ps1= "$PS 1" ' \[\033[33m\] '       # change colorPS1 = "$PS 1" ' \w '                 # Current working directory

Change to:

ps1= "$PS 1" ' \w '                 # Current Working nameps1= "$PS 1" ' \[\033[33m\] '       # change colorps1= ' $PS 1 ' ' \$ '                 # End Add < space>$

  

Mac Location:
~/.bash_profile

  

Specific set production test:

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

Git tutorials:

Http://git-scm.com/docs

Gitforwindows Chinese garbled problem:

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

Mac Oh_my_zsh Terminal small yellow fork tip:

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

Other similar documents:

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

git terminal prompt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.