DEV Community

LG
LG

Posted on

1

Git bash for Windows users PS1 variable (aka prompt) customization

This assumes that you are located in %USERPROFILE% (File Explorer), otherwise, init Git bash for Windows shell session at cd ~: once you are there, touch .bash_profile via Git the bash session. Following these third-party guidelines (see link) we can customize our PS1 as we want to:

MY_ALIAS="vanillacamp"
export PS1='\e[0;32m$MY_ALIAS@\[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
Enter fullscreen mode Exit fullscreen mode

Let's clarify the snippet above:

  • MY_ALIAS is a bash variable, that later on will be referred to using a dollar sign as the following: $MY_ALIAS

  • the export keyword makes sure the PS1 will be valid among sessions (system-wise)

  • PS1 variables follow ANSI-escaping standards for colouring and formatting including some special escape sequences such as \u for system (admin) username, or relevant

  • the $MSYSTEM is part of MSYS2 toolchain; depending on platform $MSYSTEM most likely be one of the following values: MINGW32|MINGW64|MSYS

  • __git_ps1 is part of Git version control that, essentially, provides the current branch as part of your prompt, thus PS1 variable you currently trying to modify

Happy modifying, cheers!

Image of Quadratic

Free AI chart generator

Upload data, describe your vision, and get Python-powered, AI-generated charts instantly.

Try Quadratic free

Top comments (0)

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup 🚀

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

Please show some love ❤️ or share a kind word in the comments if you found this useful!

Got it!