norstar@tnl.UUCP (Daniel Ray) (02/01/90)
> ... > Well, here's mon, my version of cal. It works on both the SYSV AND BSD systems > that I've tried it on. It even deals with pad characters (termcap). > > It expects the termcap entry to be in the $TERMCAP variable for BSD. > > -Jeff > ... Why do something just for 'cal' when you can solve the problem once and for all, UNIX-style?! Below is a highlighting/colorizing search filter that can be used with both cal or any other strings... --------------------------start search shell script---------------------------- : # @(#) search v1 12/04/89 by Daniel Ray # The Northern Lights (TNL v2) Burlington, Vermont # RELEASED INTO THE PUBLIC DOMAIN FOR UNREGULATED DISTRIBUTION # # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ # # SEARCH: highlights search expression via sed, can be used with grep # CAUTION: requires compatible terminal whos highlight/colorization data is # available via 'tput' (TERMINFO database). Presumes the availability of # the 'setcolor' utility. # # Usage: search 'string' < /file/name (highlights string) # prog | search 'string' (highlights string) # search 'string' /file/name (highlights string) # prog | search -l 'string' (highlights whole line) # # prog | search color1 color2 'string' (uses color instead of inv vid. # Sets foreground color only. # 'color2' arg should be the # CURRENT foreground color in # in use prior to using search) # # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ # case "$3" in "") ;; *) smso=`/usr/bin/setcolor $1` ; rmso=`/usr/bin/setcolor $2` shift ; shift ; /bin/sed "s/$1/${smso}$1${rmso}/g" $2 ; exit 0 ;; esac smso=`/usr/bin/tput smso 2>/dev/null | /bin/tr "&" "="` rmso=`/usr/bin/tput rmso 2>/dev/null | /bin/tr "&" "="` case "$1" in -l) shift ; /bin/sed "s/^.*$1.*$/${smso}&${rmso}/" $2 ; exit 0 ;; -?*) /bin/echo "\nSEARCH TEXT HIGHLIGHTIMG Options\n search 'string' filename (highlights string in file) search -l 'string' filename (highlights line in file) search color1 color2 'string' filename (color1=foreground color highlighting) prog | search 'string' (piped output) prog | search -l 'string' (piped output, highlights whole line) prog | search color1 color2 'string' (piped color output)\n" ; exit 2 ;; esac case "$*" in "") /bin/echo "Usage: $0 [-l] 'string' [filename]" >&2 ; exit 1 ;; *) /bin/sed "s/$1/${smso}$1${rmso}/g" $2 ;; esac -------------------------end search shell script------------------------------ norstar The Northern Lights, Burlington Vermont | Still tnl dialins: 802-865-3614 at 1200-2400 bps. ` | / here ------------------------------------------- --- * --- but uucp: uunet!uvm-gen!tnl!norstar or / | . fading {decvax,linus}!dartvax!uvm-gen!tnl!norstar | fast!
kmc@leafusa.hq.ileaf.com (Keith Corbett) (02/02/90)
I was intrigued by Michael Hammel's example of a script that highlights and blinks output (from <5276@dell.dell.com>), enough to try to get it to work, and guess what. Michael has Dell (Sys5?), so somebody else may need to take a whack at this for me (I'm running on a Sun). (It's a 3/50, "running" is a relative term.) (I don't code with sh at all, forgive me if this is all obvious to everyone -- this is c.u.??, right?) Some fixes were obvious, to make it work more generally, i.e., on a Sun, like using the Sys5 echo. =^} ... But the script still doesn't quite work. The Sun version of date doesn't include the '%B' format; what is that supposed to be generate??? For that matter, how are you supposed to get the full 4-char year?? Note that when I run this, I get a highlighted year, but no blinking date... ? --------------------------------------------------------- #!/bin/sh PATH=/usr/5bin:/usr/bin:/bin export PATH tmp=month$$ tmp2=newmonth$$ tod=`date +%m` tod2=`date +%y` cal $tod $tod2 | sed '/^$/d' > $tmp sed 's/^/ /' $tmp > $tmp2 #obviously wrong: fix me please! tod=`date +%d` sed 's/'$tod'/'`echo "\033[7m$tod\033[0m"`'/' $tmp2 > $tmp tod=`date +%y` sed 's/'$tod'/'`echo "\033[7m$tod\033[0m"`'/' $tmp > $tmp2 sed 's/^/'`echo "\033[36m"`'/' $tmp2 > $tmp tod=`date +%d` sed 's/ '$tod' / '`echo "\033[5;33m$tod\033[0;36m"`' /' $tmp > $tmp2 echo "\033[0m" >> $tmp2 cat $tmp2 rm $tmp $tmp2 --------------------------------------------------------- (Also, scripts shouldn't try to write files into the working directory, with all the read-only file-systems one is likely to be working in =-} - -- -- Keith Corbett 617-621-0555 x1727 Cambridge, MA, USA UUnet: uunet!leafusa!kmc via Internet: leafusa!kmc@uunet.uu.net Uucp: mit-eddie!ileaf!kmc via Internet: kmc@ileaf.com Book recommendation: "Foucault's Pendulum", Umberto Eco
jba@harald.ruc.dk (Jan B. Andersen) (02/02/90)
jiang@hbar.rice.edu (Jun Jiang) writes: >I am trying to write a shell script which should be able to print >something in highlighted text. Does anyone out there have any idea >how to do it? Thanks a lot. If you have terminfo this should work: % bold=`tput bold` % normal=`tput sgr0` % echo $bold Some text $normal