Created
April 9, 2021 10:58
-
-
Save oscar230/05f8b3094edcfb2013f8c3ccae08bc0d to your computer and use it in GitHub Desktop.
Bash PS1 mildly styleized with current git branch
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\[$(tput bold)\]\[\033[38;5;10m\]\u@\[$(tput sgr0)\]\[\033[38;5;165m\]\h\[$(tput sgr0)\]:\[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;12m\]\w\[$(tput sgr0)\]\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\\$ \[$(tput sgr0)\]" |
Update: Use this for narrow terminals (my particular use is for WSL2 on a laptop with vscode on the same screen.)
Recommended source for bash esthetical formatting: https://misc.flogisoft.com/bash/tip_colors_and_formatting
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[$(tput bold)\]\[\033[38;5;10m\]\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;4m\]\h\[$(tput sgr0)\]:\[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;11m\]\w\[$(tput sgr0)\]\[\033[38;5;200m\]\$(parse_git_branch)\[\033[00m\]\\n\$ \[$(tput sgr0)\]"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Preview, user is green, hostname is purple, partial path is blue and git branch (if any) is gold.