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 Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more