Skip to content

Instantly share code, notes, and snippets.

@oscar230
Created April 9, 2021 10:58
Show Gist options
  • Save oscar230/05f8b3094edcfb2013f8c3ccae08bc0d to your computer and use it in GitHub Desktop.
Save oscar230/05f8b3094edcfb2013f8c3ccae08bc0d to your computer and use it in GitHub Desktop.
Bash PS1 mildly styleized with current git branch
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)\]"
@oscar230
Copy link
Author

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)\]"

Screenshot 2021-08-19 124319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment