Created
May 2, 2016 12:36
-
-
Save lorello/aa726de356e0c9cc033aa316e85b164a to your computer and use it in GitHub Desktop.
Ubuntu Two-Lines Prompt with GIT and SVN info
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
| # A two-line colored Bash prompt (PS1) with Git branch and a line decoration | |
| # which adjusts automatically to the width of the terminal. | |
| # Recognizes and shows Git, SVN and Fossil branch/revision. | |
| # Screenshot: http://img194.imageshack.us/img194/2154/twolineprompt.png | |
| # Michal Kottman, 2012 | |
| RESET="\[\033[0m\]" | |
| RED="\[\033[0;31m\]" | |
| GREEN="\[\033[01;32m\]" | |
| BLUE="\[\033[01;34m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| # Ubuntu colors (grey / aubergine / orange) | |
| STRONG_ORANGE="\[\e[38;5;202m\]" | |
| GRAY="\[\e[38;5;245m\]" # gray | |
| ORANGE="\[\e[38;5;172m\]" # orange | |
| AUBERGINE="\[\e[38;5;5m\]" # aubergine | |
| #PS1="${debian_chroot:+($debian_chroot)}\[\e[38;5;202m\]\$(byobu_prompt_status)\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;172m\]\h\[\e[00m\]:\[\e[38;5;5m\]\w\[\e[00m\]\$(byobu_prompt_symbol) " | |
| PS_LINE=`printf -- '- %.0s' {1..200}` | |
| function parse_git_branch { | |
| PS_BRANCH='' | |
| PS_FILL=${PS_LINE:0:$COLUMNS} | |
| if [ -d .svn ]; then | |
| PS_BRANCH="(svn r$(svn info|awk '/Revision/{print $2}'))" | |
| return | |
| elif [ -f _FOSSIL_ -o -f .fslckout ]; then | |
| PS_BRANCH="(fossil $(fossil status|awk '/tags/{print $2}')) " | |
| return | |
| fi | |
| ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
| PS_BRANCH="(git ${ref#refs/heads/}) " | |
| } | |
| prompt_symbol() { | |
| if [ "$USER" = "root" ]; then | |
| printf "%s" "#"; | |
| else | |
| # MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET (U+27EB, Pe): ⟫ | |
| printf "%s" "⟫" | |
| fi | |
| } | |
| export GREP_COLORS="ms=01;38;5;202:mc=01;31:sl=:cx=:fn=01;38;5;132:ln=32:bn=32:se=00;38;5;242" | |
| export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode – red | |
| export LESS_TERMCAP_md=$(printf '\e[01;38;5;180m') # enter double-bright mode – bold light orange | |
| export LESS_TERMCAP_me=$(printf '\e[0m') # turn off all appearance modes (mb, md, so, us) | |
| export LESS_TERMCAP_se=$(printf '\e[0m') # leave standout mode | |
| export LESS_TERMCAP_so=$(printf '\e[03;38;5;202m') # enter standout mode – orange background highlight (or italics) | |
| export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode | |
| export LESS_TERMCAP_us=$(printf '\e[04;38;5;139m') # enter underline mode – underline aubergine | |
| # Use Ubuntu themed dircolors | |
| #if [ -e "/usr/share/byobu/profiles/dircolors" ]; then | |
| #dircolors "usr/share/byobu/profiles/dircolors" > "$BYOBU_RUN_DIR/dircolors" | |
| #. "$BYOBU_RUN_DIR/dircolors" | |
| #fi | |
| PROMPT_COMMAND=parse_git_branch | |
| PS_INFO="$GRAY\u$RESET@$ORANGE\h$RESET:$AUBERGINE\w" | |
| PS_GIT="$STRONG_ORANGE\$PS_BRANCH" | |
| PS_TIME="\[\033[\$((COLUMNS-10))G\] $AUBERGINE[\t]" | |
| export PS1="\${PS_FILL}\[\033[0G\]${PS_INFO} ${PS_GIT}${PS_TIME}\n${RESET}\$(prompt_symbol) " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment