# # Simple bash completion for LEDA manual commands Lman and Fman. # # Copyright (C) Dimitris Michail # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # The latest version of this software can be obtained here: # # http://www.mpi-sb.mpg.de/~michail # # # The first time bash completion is executed, variable LEDA_LMAN_FILES # is populated with all manual pages. After that all calls are # handled by this global variable (due to speed reasons). # # Install by appending this file to ~/.bash_completion # # Make sure that Fman and Lman are in the path. Do this in the following # way. Add the following lines to your ~/.bashrc # # export LEDAROOT=/path/to/leda/root/dir # export PATH="$PATH:$LEDAROOT/Manual/cmd" # export TEXINPUTS=":$LEDAROOT/Manual/tex" # # In case you need to regenerate the completions on the same session, # set LEDA_LMAN_FILES to the empty string, with # export LEDA_LMAN_FILES="" # # Enjoy! # _leda_lman() { # find path (TODO: search $LMANFILES) if [ "$LEDAROOT" = "" -o ! -d "$LEDAROOT/incl/LEDA" ]; then return 0; fi local EX="$LEDAROOT/incl/LEDA"; local cur local fname COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # check if LEDA_LMAN_FILES is already defined # and if it is not recompute it if [ "$LEDA_LMAN_FILES" = "" ]; then # list files which contain a manual entry for f in `find $EX -type f 2>/dev/null | grep -e '\.h$' | sed -e 's/\.h$//g'`; do # check if header file has a manpage if [ -e $f.h ]; then if grep '\\Manpage' $f.h 2>/dev/null 1>&2; then fname=`echo $f | sed -e 's/.*\///g'` LEDA_LMAN_FILES="$LEDA_LMAN_FILES $fname" fi fi done fi # generate completion COMPREPLY=( $( compgen -W "$LEDA_LMAN_FILES" $cur )) return 0; } complete -F _leda_lman Lman complete -F _leda_lman Fman complete -F _leda_lman Lps complete -F _leda_lman HTMLman # ex: set tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab