Created
January 30, 2025 03:44
-
-
Save giner/e9f6ac7c7d4e160d658538b214c81d55 to your computer and use it in GitHub Desktop.
Add Git info to Bash prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
# Add Git info to Bash prompt | |
bash_prompt_configuration=( | |
'PS1="${PS1%\\$ }\$(__git_ps1)\\$ "' | |
'GIT_PS1_SHOWDIRTYSTATE=1' | |
) | |
for conf in "${bash_prompt_configuration[@]}"; do | |
if ! grep -qxF "$conf" ~/.bashrc; then | |
echo "$conf" >> ~/.bashrc | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment