From 7830f362dc26a43bfcfb9c64f102d6bcf686f6f3 Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Sun, 5 May 2002 20:46:30 +0000 Subject: [PATCH] - add completion for Postfix commands (patch by Liviu Daia and Carsten Hoeger ) --- bash_completion | 108 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/bash_completion b/bash_completion index 8a127e05..ece7ee97 100644 --- a/bash_completion +++ b/bash_completion @@ -1,6 +1,6 @@ # bash_completion - some programmable completion functions for bash 2.05a # -# $Id: bash_completion,v 1.301 2002/05/05 20:29:35 ianmacd Exp $ +# $Id: bash_completion,v 1.302 2002/05/05 22:46:30 ianmacd Exp $ # # Copyright (C) Ian Macdonald # @@ -747,6 +747,112 @@ _ipsec() } [ $UNAME = Linux ] && [ "$have" ] && complete -F _ipsec ipsec +# Postfix completion. +# +have postfix && { +# postalias(1) and postmap(1) +# +_postmap() +{ + local cur prev len idx + + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $cur == '-' ]]; then + COMPREPLY=(-N -f -i -n -r -v -w -c -d -q) + return 0 + fi + if [[ $prev == '-c' ]]; then + _filedir -d + return 0 + fi + if [[ $prev == -[dq] ]]; then + return 0 + fi + + if [[ "$cur" == *:* ]]; then + COMPREPLY=( $( compgen -f -- ${cur#*:} ) ) + else + len=${#cur} + idx=0 + for pval in $( postconf -m ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]="$pval:" + idx=$(($idx+1)) + fi + done + if [[ $idx -eq 0 ]]; then + COMPREPLY=( $( compgen -f -- "$cur" ) ) + fi + fi + return 0 +} +complete -F _postmap postmap postalias + +# postconf(1) +# +_postconf() +{ + local cur prev len idx eqext + + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + if [[ $cur == '-' ]]; then + COMPREPLY=(-c -d -e -h -m -l -n -v) + return 0 + fi + if [[ $prev == '-c' ]]; then + _filedir -d + return 0 + fi + if [[ $prev == '-e' ]]; then + cur=${cur#[\"\']} + eqext='=' + fi + len=${#cur} + idx=0 + for pval in $( postconf | cut -d ' ' -f 1 ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]="$pval$eqext" + idx=$(($idx+1)) + fi + done + return 0 +} +complete -F _postconf postconf + +# postsuper(1) +# +_postsuper() +{ + local cur prev len idx + + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $cur == '-' ]]; then + COMPREPLY=(-d -p -r -s -v) + return 0 + fi + if [[ $prev == -[dr] ]]; then + len=${#cur} + idx=0 + for pval in $( mailq | \ + sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//' ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]=$pval + idx=$(($idx+1)) + fi + done + return 0 + fi + _filedir -d + return 0 +} +complete -F _postsuper postsuper +} + # cvs(1) completion # have cvs && {