Skip to content

Instantly share code, notes, and snippets.

@erfanium
Created June 10, 2024 09:18

Revisions

  1. erfanium created this gist Jun 10, 2024.
    14 changes: 14 additions & 0 deletions PS1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # Add in ~/.bashrc or ~/.bash_profile
    function parse_git_branch () {
    # The line below is changed.
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \(\1)/'
    }

    RED="\[\033[01;31m\]"
    YELLOW="\[\033[01;33m\]"
    GREEN="\[\033[01;32m\]"
    BLUE="\[\033[01;34m\]"
    NO_COLOR="\[\033[00m\]"

    # without host
    PS1="$GREEN\u$NO_COLOR:$BLUE\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "