X-Git-Url: http://git.grml.org/?p=grml-scripts.git;a=blobdiff_plain;f=usr_bin%2Fqma;h=1a4c573630c3e220a8a0643764b0617c778ce69a;hp=e36c64fd5558cec236321698ab7e534446a262b9;hb=24c1bd1dc1799b4124782c9f66267d2c4f974bb7;hpb=ad489d6103005145e9cfd9ae23d8daa458085e5e diff --git a/usr_bin/qma b/usr_bin/qma index e36c64f..1a4c573 100755 --- a/usr_bin/qma +++ b/usr_bin/qma @@ -1,22 +1,20 @@ #!/bin/zsh # Filename: qma # Purpose: "quick manual access" -# Authors: grml-team (grml.org), (c) Michael Prokop +# Authors: grml-team (grml.org), (c) Michael Prokop , Matthias Kopfermann # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Son Dez 03 00:24:00 CET 2006 [mika] +# Latest change: Sam Dez 16 17:24:05 CET 2006 [maddi] ################################################################################ -# Idea for this script and basic functionally by Matthias Kopfermann . - . /etc/grml/lsb-functions . /etc/grml/script-functions check4progs man lzop vim || exit 1 -MANDIR=${MANDIR:-$HOME/man} VERSION='0.1' +MANDIR=${MANDIR:-$HOME/man} if ! [ -d "$MANDIR" ] ; then einfo "Creating $MANDIR." mkdir $MANDIR ; eend $? @@ -48,26 +46,73 @@ case $1 in ;; esac + if [ -z "$MANPAGE" ] ; then usage fi -if ! [ -f "${MANDIR}/${MANPAGE}${SECTIONFILE}.txt.lzo" ] ; then - einfo "Writing manpage to ${MANDIR}/${MANPAGE}${SECTIONFILE}.txt" +QUICKMAN="${MANDIR}/${MANPAGE}${SECTIONFILE}.txt.lzo" + +if ! [ -f "$QUICKMAN" ] ; then + einfo "Writing manpage to $QUICKMAN" if man $SECTION $MANPAGE 1>/dev/null ; then - man $SECTION $MANPAGE > ${MANDIR}/${MANPAGE}${SECTIONFILE}.txt ; eend $? + man $SECTION $MANPAGE | lzop -U >$QUICKMAN ; eend $? einfo "Compressing manpage with lzop" - lzop -U ${MANDIR}/${MANPAGE}${SECTIONFILE}.txt.lzo ${MANDIR}/${MANPAGE}${SECTIONFILE}.txt ; eend $? + eend $? else exit 1 eend 1 fi fi +vimconfig=' + set filetype=man + "set hlsearch can be annoying so use to dehighlight" + "shut up hlsearch when it confuses more than it helps and" + nn :nohlsearch|redraw + "q should really end our document-reading like less does" + nn q :qa! + "different than q in that it quits only the current window when multiple windows " + nn Q :q! + "honor midnight-commander addicts :) " + nn :qa! + "use one wonderful vim feature to show all matches of the word in the document in ex-mode" + nn a ]I + "the other way round" + nn A [I + nn b + nn + "nn f + nn p }zz + "scroll the page down one line" + nn j + "scroll the page up one line" + nn k + "the expectation of getting the next search via 'n' can not be ignored" + nn -n :set invnumber + nn h :set invhlsearch + "Make toggling case-sensitive accessable via the letter i" + nn i :set invignorecase + "Make toggling case-sensitive accessable via the less convention via -i" + nn -i :set invignorecase + nn + nn + nn gg + nn S :split + nn V :vsplit + set filetype=man + set ignorecase + "Really not modify a document here" + set nomodifiable + set readonly + "We have a more modern approach to searching in vim!" + set incsearch +' + if [ -n "$SEARCH" ] ; then - vim -c "set ft=man | set hlsearch | set ignorecase" +/"$SEARCH" =( lzop -cd $MANDIR/${MANPAGE}${SECTIONFILE}.txt.lzo) + vim -S =( echo $vimconfig ) +/"$SEARCH" =( lzop -cd ${QUICKMAN} ) else - vim -c 'set ft=man' =( lzop -cd $MANDIR/${MANPAGE}${SECTIONFILE}.txt.lzo) + vim -S =( echo $vimconfig ) =( lzop -cd $QUICKMAN ) fi einfo "Thanks for flying qma using vim and lzop." ; eend 0