Skip to content
Snippets Groups Projects

bashrc git

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Isabella Skořepová
    .bashrc 857 B
    function color_my_prompt {
        local __user_and_host="\[\033[01;32m\]\u@\h"
        local __cur_location_color="\[\033[01;34m\]"
        local __cur_location="\$(name=\$(python -c \"import os.path; p='\$(git rev-parse --show-toplevel 2> /dev/null)/..'; print (os.path.relpath('\$(pwd)', p) if p != '/..' else '\$(pwd)');\")"
        __cur_location="$__cur_location;[[ \"\$name\" =~ ^\"$HOME\"(/|$) ]] && name=\"~\${name#$HOME}\";echo \$name)"
        #local __cur_location="\[\033[01;34m\]\w"
        local __git_branch_color="\[\033[31m\]"
        local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E  s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
        local __prompt_tail="\n\[\033[35m\]$"
        local __last_color="\[\033[00m\]"
        export PS1="$__user_and_host $__cur_location_color$__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
    }
    color_my_prompt
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment