-
-
Save andrematias/1b6c5c60c6e9781cb1610aaffb8b0d16 to your computer and use it in GitHub Desktop.
Add this snippet in Linux (Ubuntu)'s `~/.bashrc` to see your current git-branch in terminal prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author : Shiva Bhusal | |
# github: shivabhusal | |
# stackoverflow: users/3437900/illusionist | |
########################################## | |
# Usages: | |
# - create a file called ~/.promptrc | |
# - add following in ~/.bashrc | |
# `source ~/.promptrc` | |
# # this will include the source of the file | |
# Content of the file ~/.promptrc | |
# @returns {String} | |
# Eg: master | |
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[0;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
NO_COLOR="\[\033[0m\]" | |
RUBY_VERSION="\$(~/.rvm/bin/rvm-prompt)" | |
# \w --> working directory | |
# \u --> current user | |
# \h --> Computer name | |
export PS1="$GREEN\u:$BLUE\w$YELLOW (${RUBY_VERSION} : $(parse_git_branch)) $NO_COLOR$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment