Published
My custom bash prompt
This is my custom bash prompt, as defined in my profile (~/.bash_profile
). It includes a custom character for the prompt, the path, and the Git branch name (if any). The whole thing is colorful to make it a bit easier to identify the prompt in a sea of characters.
When I’m working on this WordPress theme for example, it looks sort of like this (RSS readers, you’ll miss the colors):
→ ~/sites/commonplace-wp-theme (v0.1.5)
To generate something else, try messing around with the Bash $PS1 Generator.
If you want to try something like this, do not delete the rest of your profile. Just add this at the top.
# Get the Git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Custom bash prompt
# Includes custom character for the prompt, the path, and Git branch name. With colors!
# Source: kirsle.net/wizards/ps1.html
export PS1="\n\[$(tput bold)\]\[$(tput setaf 5)\]➜ \[$(tput setaf 6)\]\w\[$(tput setaf 3)\]\$(parse_git_branch) \[$(tput sgr0)\]"
Note: I got this from someone else at some point… I’m trying to figure out who but haven’t gotten to the bottom of it.