Skip to content

Instantly share code, notes, and snippets.

@inspector71
Last active June 24, 2024 10:55

Revisions

  1. inspector71 revised this gist Jun 24, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[30;47m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[37m\]\h\[\e[m\]\[\e[33m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36m\]\`parse_git_branch\`\[\e[m\] \[\e[35m\]/\[\e[m\]\[\e[33m\]:\[\e[m\] "
    export PS1="\[\e[30;47m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[37m\]\H\[\e[m\]\[\e[33m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36m\]\`parse_git_branch\`\[\e[m\] \[\e[35m\]/\[\e[m\]\[\e[33m\]:\[\e[m\] "
  2. inspector71 renamed this gist Mar 4, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. inspector71 revised this gist Sep 24, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[30;47m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]\[\e[37m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36;40m\]\`parse_git_branch\`\[\e[m\]:\[\e[33m\]/\[\e[m\] "
    export PS1="\[\e[30;47m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[37m\]\h\[\e[m\]\[\e[33m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36m\]\`parse_git_branch\`\[\e[m\] \[\e[35m\]/\[\e[m\]\[\e[33m\]:\[\e[m\] "
  4. inspector71 revised this gist Sep 24, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[30;47m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]\[\e[37m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36;45m\]\`parse_git_branch\`\[\e[m\]:\[\e[33m\]/\[\e[m\] "
    export PS1="\[\e[30;47m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]\[\e[37m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36;40m\]\`parse_git_branch\`\[\e[m\]:\[\e[33m\]/\[\e[m\] "
  5. inspector71 revised this gist Sep 24, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[30;47m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]\[\e[33m\]:\[\e[m\]\[\e[36;45m\]\`parse_git_branch\`\[\e[m\]\[\e[33m\]/\[\e[m\] "
    export PS1="\[\e[30;47m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]\[\e[37m\]:\[\e[m\]\[\e[35m\]\w\[\e[m\] \[\e[36;45m\]\`parse_git_branch\`\[\e[m\]:\[\e[33m\]/\[\e[m\] "
  6. inspector71 revised this gist Sep 24, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[35;44m\]\u\[\e[m\]@\[\e[42m\]\h\[\e[m\]:\[\e[35m\]\w\[\e[m\] \[\e[36m\]\`parse_git_branch\`\[\e[m\] \[\e[33m\]/\[\e[m\] "
    export PS1="\[\e[30;47m\]\u\[\e[m\]@\[\e[36m\]\h\[\e[m\]\[\e[33m\]:\[\e[m\]\[\e[36;45m\]\`parse_git_branch\`\[\e[m\]\[\e[33m\]/\[\e[m\] "
  7. inspector71 revised this gist Sep 24, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # Thanks to http://ezprompt.net/
    # get current branch in git repo
    function parse_git_branch() {
    BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
    @@ -45,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[35;44m\]\u\[\e[m\]@\h-\w\[\e[36m\]\`parse_git_branch\`\[\e[m\]/: "
    export PS1="\[\e[35;44m\]\u\[\e[m\]@\[\e[42m\]\h\[\e[m\]:\[\e[35m\]\w\[\e[m\] \[\e[36m\]\`parse_git_branch\`\[\e[m\] \[\e[33m\]/\[\e[m\] "
  8. inspector71 revised this gist Sep 24, 2017. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    # Thanks to http://ezprompt.net/
    # get current branch in git repo
    function parse_git_branch() {
    BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
    @@ -46,4 +45,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[35;44m\]\u\[\e[m\]@\h-\H:\w\[\e[36m\]\`parse_git_branch\`\[\e[m\]/ "
    export PS1="\[\e[35;44m\]\u\[\e[m\]@\h-\w\[\e[36m\]\`parse_git_branch\`\[\e[m\]/: "
  9. inspector71 revised this gist Sep 24, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ function parse_git_dirty {
    fi
    }

    export PS1="\[\e[35;44m\]\u\[\e[m\]@\H:\w[\`parse_git_branch\`]\\$ "
    export PS1="\[\e[35;44m\]\u\[\e[m\]@\h-\H:\w\[\e[36m\]\`parse_git_branch\`\[\e[m\]/ "
  10. inspector71 created this gist Sep 24, 2017.
    49 changes: 49 additions & 0 deletions .colour-prompt.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    # Thanks to http://ezprompt.net/
    # get current branch in git repo
    function parse_git_branch() {
    BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
    if [ ! "${BRANCH}" == "" ]
    then
    STAT=`parse_git_dirty`
    echo "[${BRANCH}${STAT}]"
    else
    echo ""
    fi
    }

    # get current status of git repo
    function parse_git_dirty {
    status=`git status 2>&1 | tee`
    dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
    untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
    ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
    newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
    renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
    deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
    bits=''
    if [ "${renamed}" == "0" ]; then
    bits=">${bits}"
    fi
    if [ "${ahead}" == "0" ]; then
    bits="*${bits}"
    fi
    if [ "${newfile}" == "0" ]; then
    bits="+${bits}"
    fi
    if [ "${untracked}" == "0" ]; then
    bits="?${bits}"
    fi
    if [ "${deleted}" == "0" ]; then
    bits="x${bits}"
    fi
    if [ "${dirty}" == "0" ]; then
    bits="!${bits}"
    fi
    if [ ! "${bits}" == "" ]; then
    echo " ${bits}"
    else
    echo ""
    fi
    }

    export PS1="\[\e[35;44m\]\u\[\e[m\]@\H:\w[\`parse_git_branch\`]\\$ "