Skip to content

Instantly share code, notes, and snippets.

@geoom
Created December 3, 2014 21:20
Show Gist options
  • Select an option

  • Save geoom/0d7207e6f8c4dbdf6be6 to your computer and use it in GitHub Desktop.

Select an option

Save geoom/0d7207e6f8c4dbdf6be6 to your computer and use it in GitHub Desktop.

Revisions

  1. geoom created this gist Dec 3, 2014.
    24 changes: 24 additions & 0 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #################################################### On linux put them on .bashrc file

    # Add git branch if its present to PS1
    parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
    }
    if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
    else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
    fi
    unset color_prompt force_color_prompt

    ################################################### On mac put them on .bash_profile file

    # Git branch in prompt.

    parse_git_branch() {

    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

    }

    export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "