A small, fast, and readable Bash prompt that shows:
- 🐍 Active Python virtual environment (with version)
- 🌿 Git branch + status (clean vs dirty)
- Clean two-line layout when needed
- Zero dependencies beyond standard Git tools
-
Git integration
- Branch name
- Clean (green) vs dirty (orange) state
-
Python virtualenv awareness
- Shows env name + Python version
- Disables default venv prompt override
-
Smart layout
- Single line when idle
- Expands to two lines when Git or venv is active
-
Lightweight
- Pure Bash, no frameworks
- Bash
- Git (with
git-sh-prompt, usually included)
On most systems, the Git prompt script is located at:
/usr/lib/git-core/git-sh-promptClone the repository:
git clone https://github.com/hwblx/prompt_gv.git
cd prompt_gvAdd this line to your ~/.bashrc:
source /path/to/prompt_gv.shThen reload your shell:
source ~/.bashrcRun a clean Bash session:
bash --noprofile --norcThen load the prompt:
source ./prompt_gv.shuser@folder$(🌿 main)
user@repo$(🌿 main*)
user@repo$(🐍 venv 3.11.2)
user@project$(🐍 venv 3.11.2) (🌿 main*)
user@project$| Symbol | Meaning |
|---|---|
* |
Unstaged changes in working directory |
+ |
Staged changes ready to commit |
? |
Untracked files present |
! |
Stashed changes (if enabled) |
↑n |
Branch is n commits ahead of upstream |
↓n |
Branch is n commits behind upstream |
= |
Branch is equal (in sync) with upstream |
# |
No HEAD (fresh repository) |
% |
Repo has untracked files (fresh repository) |
The prompt uses Git’s built-in __git_ps1 with:
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_SHOWCOLORHINTS=trueYou can tweak these in prompt.sh.
-
The script must be sourced, not executed:
source prompt_gv.sh -
Designed for Bash only
-
Tested on Linux environments
- Change colors (ANSI codes in script)
- Replace icons (🐍, branch symbol)
- Add exit status or execution time
- Add Kubernetes / Docker context
Make sure:
type __git_ps1If not found, verify the path to git-sh-prompt.
Check:
echo $PROMPT_COMMANDShould output:
set_prompt- Git’s
__git_ps1prompt helper - Inspired by minimal prompt setups and developer workflows