Recommend a shell custom prompt sexy solarized Bash Prompt

Source: Internet
Author: User
Tags svn

Prompt effect:


Code:

# sexy solarized bash prompt, inspired by  "Extravagant Zsh Prompt "# customized for the solarized color scheme by sean o ' Neilif  tput setaf 1 &> /dev/null; then    if [[ $ (tput colors)  -ge 256 ]] 2>/dev/null; then       base03=$ (tput setaf 234)       base02=$ (tput setaf 235)       base01=$ (tput setaf 240)        base00=$ (tput setaf 241)       base0=$ (tput setaf 244)        base1=$ (tput setaf 245)       base2=$ ( tput setaf 254)       base3=$ (tput setaf 230)        yellow=$ (tput setaf 136)       orange=$ (tput setaf 166)        red=$ (tput setaf 160)       magenta=$ (tput  setaf 125)       violet=$ (tput setaf 61)        blue=$ (tput setaf 33)       cyan=$ (TPUT SETAF  37)       green=$ (tput setaf 64)     else       base03=$ (tput setaf 8)       base02 =$ (tput setaf 0)       base01=$ (tput setaf 10)        base00=$ (tput setaf 11)       base0=$ (tput  SETAF 12)       base1=$ (tput setaf 14)        base2=$ (Tput setaf 7)       base3=$ (tput setaf 15)        yellow=$ (tput setaf 3)       orange=$ (tput setaf 9)       red=$ (tput setaf 1)       magenta=$ (tput setaf 5)       violet=$ (tput setaf 13)        blue=$ (tput setaf 4)       cyan=$ (tput  setaf 6)       green=$ (tput setaf 2)     fi     bold=$ (Tput bold)     reset=$ (tput sgr0) else     # linux console colors. i don ' t have the energy     # to figure out the Solarized values     Magenta= "\033[1;31m"   &nbSp; orange= "\033[1;33m"     green= "\033[1;32m"     purple= "\033[1"; 35m "    white=" \033[1;37m "    bold=" "    reset=" \ 033[m "fiparse_git_dirty  ()  {    [[ $ (git status 2> /dev/ NULL | TAIL -N1)  !=  "nothing to commit, working directory  Clean " ]] && echo " * "}parse_git_branch  ()  {     branch=$ (git branch --no-color 2> /dev/null | sed -e  '/^[^*]/d '  -e  "s/* \ (. *\)/\1$ (parse_git_dirty)/")     echo  $branch}parse_svn_ Branch ()  {    svn info &> /dev/null && parse_ Svn_url}parse_svn_url ()  {    local url=$ (svn info 2>/dev/null  | sed -ne  ' s#^relative url: # #p ')     if [[  $url  =~ trunk ]];  then        echo trunk    elif [[ $ url =~ /branches/ ]]; then        echo  $url  | sed -e  ' s#^.*/branches/\ ([^/]*\). *$ #branch: \1# '     elif [[   $url  =~ /tags/ ]]; then        echo $ url | sed -e  ' s#^.*/tags/\ ([^/]*\). *$ #tag: \1# '     fi}parse_vcs ()   {    branch=$ (Parse_git_branch)     if [ -n  "$branch"  ]; then        echo  $branch      Else        parse_svn_branch    fi}ps1= "\[${BOLD}$ {cyan}\]\u \[$BASE 0\]in \[$BLUE \]\w\[$BASE 0\]\$ ([[ -n \$ (git branch 2> /dev/null)  | |  -n \$ (svn info 2> /dev/null)  ]] && echo \ " on  \ ") \[$YELLOW \]\$ (parse_vcs) \[$BASE 0\] \$ \[$RESET \]"


How to use:

. Save the code to ~/prompt.sh edit. BASHRC, append a line of script:. ~/prompt.sh


Precautions:

. You can manually execute the script before debugging the effect:. ~/prompt.sh If there is a carriage return \ R and other errors, please edit the next prompt.sh, delete the Windows return in the \ r, because Linux is just not a newline character \ n.


Recommend a shell custom prompt sexy solarized Bash Prompt

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.