#!/bin/bash # Title........: wisdom # Description..: Run once a day to improve your mind # Author.......: Mitchell Johnston - uid 0 # Last Modified: Thu Sep 03 2009 #---------------------------------- # variables #---------------------------------- AWKSCRIPT="/tmp/random.awk.$$" CMDS="/var/tmp/cmds.dat" # colorize man export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode – red export LESS_TERMCAP_md=$(printf '\e[01;35m') # enter double-bright mode – bold, magenta 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[01;33m') # enter standout mode – yellow export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode export LESS_TERMCAP_us=$(printf '\e[04;36m') # enter underline mode – cyan # functions #---------------------------------- # main #---------------------------------- if [ ! -f $CMDS ] # if no command listing, make one then find /usr/bin >$CMDS find /usr/sbin >>$CMDS fi cat << "EOF" > $AWKSCRIPT ## write out script BEGIN { srand(); } { s[NR] = $0 } END { print s[randint(NR)] } function randint(n) { return int (n * rand() ) + 1 } EOF ## grab one and then do a man against the base name w/o path data NAME=$(nawk -f $AWKSCRIPT < $CMDS) if [ $# -gt 0 ] then man $(basename $NAME)|head -25 else man $(basename $NAME) fi