Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rodrigondec/f26d0fe3a364af107fc231dc56456d96 to your computer and use it in GitHub Desktop.

Select an option

Save rodrigondec/f26d0fe3a364af107fc231dc56456d96 to your computer and use it in GitHub Desktop.

Revisions

  1. rodrigondec created this gist Jul 14, 2022.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash/13864829#13864829
    # https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
    # https://stackoverflow.com/a/5947802
    # https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
    git_branch() {
    branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
    BEGIN_CYAN='\033[0;36m'
    END_CYAN='\033[0m'
    if [ -z "$branch" ]
    then
    echo ""
    else
    echo -e " ${BEGIN_CYAN}{$branch}${END_CYAN} "
    fi
    }
    export PS1="\[\e]0;\u: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(git_branch)\$ "