sign inHome | Recent Changes | All Pages | HelpSearch:

Bash Colors

Pretty red, and green prompt

Save this as xmas_colors, and run

. xmas_colors

A literal “dot”


#!/bin/sh

echo
echo "*** To turn off xmas_colors run xmas_over ***" 
echo

PS1_BACKUP=$PS1

xmas()
{
    local c0=$'\e'[31m
    local c1=$'\e'[32m
    local normal=$'\e'[0m
    local pcolor="c$(( ${PROMPT_NUMBER:=0} % 2 ))" 
    PS1="${!pcolor}$PS1_BACKUP${normal}" 
    let PROMPT_NUMBER=PROMPT_NUMBER+1
}

PROMPT_COMMAND="xmas" 

xmas_over()
{
    local normal=$'\e'[0m
    PS1=$PS1_BACKUP
    unset PROMPT_NUMBER
    unset PS1_BACKUP
    unset PROMPT_COMMAND
    unset xmas
    unset xmas_over
}

Powered by JunebugWiki v0.0.28 Last edited by robbyrussell on February 06, 2007 08:12 AM (diff)
Version 2 (current) «olderversions