Skip to content

Instantly share code, notes, and snippets.

@atuleu
Last active January 6, 2016 14:26

Revisions

  1. atuleu revised this gist Jan 6, 2016. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -74,11 +74,12 @@ function __prompt_command
    PS1+="$green$check_mark$reset"
    fi

    # optionally one would like to call __today_zodiac to update the sign for each command. Kind of overkill
    # __today_zodiac sign_of_birth
    # optionally one would like to call __today_zodiac to update the sign for each command. Kind of overkill
    # __today_zodiac sign_of_birth

    # the rest is a usual prompt displaying, here with __git_ps1
    # the rest is a usual prompt displaying, here with __git_ps1
    PS1+=" \d|$bold\@$reset $yellow\w\n$green$bold\u$reset@$cyan\h$reset$red\$( __git_ps1 '(%s)')$reset $bold$sign_of_birth$reset "
    }

    #simply sets the prompt to use a prompt command
    export PROMPT_COMMAND=__prompt_command
  2. atuleu created this gist Jan 6, 2016.
    84 changes: 84 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,84 @@
    # This is a funny prompt that would display the zodiac sign corresponding to the date of creation (date when the file is sourced)

    # computes the right UTF-8 zodiac sign from today's date
    function __today_zodiac
    {
    local today=$(date +%m%d)

    if [ $today -le 0120 ]
    then
    sign=$'\u2651' # "capricorn"
    elif [ $today -le 0219 ]
    then
    sign=$'\u2652' # "aquarius"
    elif [ $today -le 0320 ]
    then
    sign=$'\u2653' # "pisces"
    elif [ $today -le 0420 ]
    then
    sign=$'\u2648' # "aries"
    elif [ $today -le 0521 ]
    then
    sign=$'\u2649' # "taurus"
    elif [ $today -le 0621 ]
    then
    sign=$'\u264a' # "gemini"
    elif [ $today -le 0722 ]
    then
    sign=$'\u264b' # "cancer"
    elif [ $today -le 0822 ]
    then
    sign=$'\u264c' # "leo"
    elif [ $today -le 0923 ]
    then
    sign=$'\u264d' # "virgo"
    elif [ $today -le 1023 ]
    then
    sign=$'\u264e' # "libra"
    elif [ $today -le 1122 ]
    then
    sign=$'\u264f' # "scorpio"
    elif [ $today -le 1221 ]
    then
    sign=$'\u2650' # "sagittarius"
    else
    sign=$'\u2651' # "capricorn"
    fi

    eval "$1='$sign'"
    }

    # saves the today's zodiac in a variable
    sign_of_birth=""
    __today_zodiac sign_of_birth

    # now we define the prompt in a command
    function __prompt_command
    {
    #we would like to display the last return code
    local EXIT="$?"
    local reset="\[\033[0m\]"
    local green="\[\033[32m\]"
    local bold="\[\033[1m\]"
    local cyan="\[\033[36m\]"
    local yellow="\[\033[33m\]"
    local red="\[\033[31m\]"

    local check_mark=$'\u2713'
    local ballot_x=$'\u2717'
    PS1=""
    if [ $EXIT != 0 ]
    then
    PS1+="$red$ballot_x$reset ($EXIT)"
    else
    PS1+="$green$check_mark$reset"
    fi

    # optionally one would like to call __today_zodiac to update the sign for each command. Kind of overkill
    # __today_zodiac sign_of_birth

    # the rest is a usual prompt displaying, here with __git_ps1
    PS1+=" \d|$bold\@$reset $yellow\w\n$green$bold\u$reset@$cyan\h$reset$red\$( __git_ps1 '(%s)')$reset $bold$sign_of_birth$reset "
    }
    #simply sets the prompt to use a prompt command
    export PROMPT_COMMAND=__prompt_command