Back to BlogDevOps
Simplifying Git Bash Prompt on Windows for a Cleaner Developer Workflow
Default Git Bash prompts display the full path and clutter your terminal. Here's how to configure PS1 and PROMPT_DIRTRIM for a cleaner developer experience.
May 19, 20262 min read66 views
The Problem
Default Git Bash prompts display the full working path — e.g., Hasib@DESKTOP-V78OLS6 MINGW64 /d/2025/PROJECTS/VSCODE/TestAI/demo/myproject — which becomes unreadable in deeply nested directories.
Solution
Open ~/.bashrc and add:
export PROMPT_DIRTRIM=2
PS1='\w \$ '
Then reload: source ~/.bashrc
Prompt Variable Reference
| Variable | Purpose |
|---|---|
\u |
Username |
\h |
Hostname |
\w |
Full directory path |
\W |
Current folder only |
\$ |
Prompt symbol |
Alternative Styles
Current folder only:
PS1='\W \$ '
# Result: myproject $
Username + folder:
PS1='\u \W \$ '
# Result: Hasib myproject $
Username + hostname + folder:
PS1='\u@\h \W \$ '
# Result: Hasib@DESKTOP myproject $
Bonus: Virtual Environment Shortcut
alias venv='source .venv/Scripts/activate'
Benefits
- Cleaner terminal interface
- Improved readability
- Better space for command output and logs
- Professional developer experience
Particularly useful for Python, Node.js, DevOps, Kubernetes, Terraform, and data engineering workflows.
Sheikh Wasiu Al Hasib
Senior DevOps Engineer & DBA
Comments
No comments yet. Be the first to share your thoughts.