#!/bin/zsh # # $Id: howto,v 1.1 2004/06/20 15:22:57 dope Exp dope $ # # The "howto" script tries to find howto-files and FAQs, # if used like "howto --find part_of_the_filename", # e.g. "howto --find zsh" could return zsh-faq.html zsh-faq.txt # # If used like "howto zsh-faq.html", it will search for # exactly that file and use lynx or netscape to view it. # # Complete a howto-filename or FAQ-name (see howto script below). # Use like "howto zsh[TAB]". # | $ howtocomplete() { reply=(`howto --find "$1"`) } # | $ compctl -U -K howtocomplete howto #cd /usr/doc/Linux-HOWTOs cd /backups/Documentations/Linux-HOWTOs if [[ "$1" == "-x" ]] ; then BROWSER=opera shift fi if [[ "$1" == "--find" ]] ; then shift what=$1 all=(`find ${where[@]} -iname "*$what*" -printf "%f\n" \ | sed "s/-\?[0-9]\?[0-9]\././"`) typeset -U all echo "${all[@]}" else doc=$(find ${where[@]} -name "$1" |head -1) [[ -z $doc ]] && print 'Sorry, did not find exactly that. Try again and use the TAB (completion) key.' || ${BROWSER:-lynx} "$doc" fi cd - >/dev/null 2>&1