#!/bin/sh PROG=$(basename "$1") PREFIX="$2" if [ "$PROG" = "apt-get" ] || [ "$PROG" = "agi" ] || [ "$PROG" = "agr" ] ; then apt-cache pkgnames "$PREFIX" elif [ "$PROG" = bibtex ] ; then ls -d "$PREFIX"*.tex 2> /dev/null | sed -e 's/\.tex$//' elif [ "$PROG" = complete ] ; then . ~/.bash_completion complete | sed -e 's/.* //' elif [ "$PROG" = cvs ] ; then #sed -e 's|[^/]*/||' -e 's|/.*||' < CVS/Entries | grep -v '^D$' PREFIXDIR=`dirname "$PREFIX."` ENTRIES="$PREFIXDIR/CVS/Entries" [ -f "$ENTRIES" ] || exit 0 [ $PREFIXDIR != . ] && PRINTDIR="$PREFIXDIR/" perl -ne "print \"$PRINTDIR\$1\\n\" if m|^/([^/]+)/|" "$ENTRIES" elif [ "$PROG" = mailsync ] ; then egrep '^(channel|store)' ~/.mailsync | cut -d ' ' -f 2 elif [ "$PROG" = make ] ; then [ -f Makefile ] || exit 0 perl -ne 'print "$1\n" if /^([^ :]+):/' Makefile elif [ "$PROG" = man ] ; then if [ -f $TMP/whatis.cache ] ; then egrep "^$PREFIX" $TMP/whatis.cache else whatis -w "$PREFIX*" | cut -d ' ' -f 1 | grep -v ':$' fi elif [ "$PROG" = mutt ] ; then MUTT=$HOME/.mutt cut -d ' ' -f 2 $MUTT/aliases $MUTT/aliases.addressbook| egrep "^$PREFIX" elif [ "$PROG" = ssh ] ; then perl -lne 's/^#| .*|^\[|\].*//g; foreach (split /,/) { print if /\.(com|de|dmz|lan|net|org)$/ }' ~/.ssh/known_hosts elif [ "$PROG" = scp ] || [ "$PROG" = rsync ] ; then perl -lne 's/^#| .*|^\[|\].*//g; foreach (split /,/) { print "$_:" if /\.(com|de|dmz|lan|net|org)$/ }' ~/.ssh/known_hosts elif [ "$PROG" = super ] ; then cut -f 1 /etc/super.tab | egrep '^[a-z]' else echo "$0: cannot complete program $PROG, prefix $PREFIX" 1>&2 exit 1 fi