Created
May 6, 2026 22:59
-
-
Save RxDx/184cae703cab9573c21874051bda127b to your computer and use it in GitHub Desktop.
Bash PROMPT
This file contains hidden or 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
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p' | |
| } | |
| COLOR_DEF='%f' | |
| COLOR_USR='%F{243}' | |
| COLOR_DIR='%F{39}' | |
| COLOR_GIT='%F{197}' | |
| # About the prefixed `$`: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html#:~:text=Words%20in%20the%20form%20%22%24',by%20the%20ANSI%2DC%20standard. | |
| NEWLINE=$'\n' | |
| # Set zsh option for prompt substitution | |
| setopt PROMPT_SUBST | |
| export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment