summaryrefslogtreecommitdiff
path: root/crux-bashcompletion/crux_completions
blob: 77767a35265d649323c12ccf5500e7a8b25e91ea (plain)
    1 #   Bash programmable completion for crux (http://www.crux.nu) utilities
    2 # 
    3 #   Copyright (C) Håvard Moen <vanilje@netcom.no>
    4 #
    5 #   This program is free software; you can redistribute it and/or modify
    6 #   it under the terms of the GNU General Public License as published by
    7 #   the Free Software Foundation; either version 2, or (at your option)
    8 #   any later version.
    9 #
   10 #   This program is distributed in the hope that it will be useful,
   11 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 #   GNU General Public License for more details.
   14 #
   15 #   You should have received a copy of the GNU General Public License
   16 #   along with this program; if not, write to the Free Software Foundation,
   17 #   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   18 #
   19 #   RELEASE: 20020711
   20 
   21 #pkginfo completion
   22 _pkginfo ()
   23 {
   24   local cur prev
   25   COMPREPLY=()
   26   cur=${COMP_WORDS[COMP_CWORD]}
   27   prev=${COMP_WORDS[COMP_CWORD-1]}
   28 
   29 
   30   case "$prev" in
   31     --list|-l)
   32       	COMPREPLY=( $( compgen -W " $( pkginfo -i | awk ' { printf "%s ", $1 } ' ) " -- $cur ) )
   33 	return 0
   34       ;;
   35     --installed|-i)
   36       	return 0
   37       ;;
   38     --help|-h)
   39       	return 0
   40       ;;
   41     --version|-v)
   42       	return 0
   43       ;;
   44     --owner|-o|--root|-r)
   45     	if [ -z $BASH_COMPLETION ]; then
   46     		_filedir
   47 	else
   48     		COMPREPLY=( $( compgen -f $cur ) )
   49 	fi
   50       	return 0
   51       ;;
   52   esac
   53   
   54   COMPREPLY=( $( compgen -W "$( pkginfo --help | awk '/--/ { printf "%2s ", $2 }' )" -- $cur ) ) 
   55 
   56 }
   57 complete -F _pkginfo -o filenames pkginfo
   58 
   59 #pkgrm completion
   60 _pkgrm ()
   61 {
   62   local cur prev
   63   COMPREPLY=()
   64   cur=${COMP_WORDS[COMP_CWORD]}
   65   prev=${COMP_WORDS[COMP_CWORD-1]}
   66 
   67 
   68   case "$prev" in
   69     --help|-h)
   70       	return 0
   71       ;;
   72     --version|-v)
   73       	return 0
   74       ;;
   75     --root|-r)
   76     	if [ -z $BASH_COMPLETION ]; then
   77     		_filedir
   78 	else
   79     		COMPREPLY=( $( compgen -f $cur ) )
   80 	fi
   81       	return 0
   82       ;;
   83   esac
   84   
   85   if [[ $cur == -* ]]; then
   86 	  COMPREPLY=( $( compgen -W "$( pkgrm --help | awk '/--/ { printf "%2s ", $2 }' )" -- $cur ) ) 
   87   else
   88   	COMPREPLY=( $( compgen -W " $( pkginfo -i | awk ' { printf "%s ", $1 } ' ) " -- $cur ) )
   89   fi
   90 }
   91 complete -F _pkgrm -o filenames pkgrm
   92 
   93 #pkgmk completion
   94 _pkgmk ()
   95 {
   96   local cur prev
   97   COMPREPLY=()
   98   cur=${COMP_WORDS[COMP_CWORD]}
   99   prev=${COMP_WORDS[COMP_CWORD-1]}
  100 
  101 
  102   case "$prev" in
  103     --help|-h)
  104       	return 0
  105       ;;
  106     -do|--download-only)
  107     	return 0
  108 	;;
  109     -utd|--up-to-date)
  110     	return 0
  111 	;;
  112     --config-file|-cf)
  113     	if [ -z $BASH_COMPLETION ]; then
  114     		_filedir
  115 	else
  116     		COMPREPLY=( $( compgen -f $cur ) )
  117 	fi
  118       	return 0
  119       ;;
  120   esac
  121   
  122   COMPREPLY=( $( compgen -W "$( pkgmk --help | awk '/--/ { printf "%2s ", $2 }' )" -- $cur ) ) 
  123 }
  124 complete -F _pkgmk -o filenames pkgmk
  125 
  126 #pkgadd completion
  127 _pkgadd ()
  128 {
  129   local cur prev
  130   COMPREPLY=()
  131   cur=${COMP_WORDS[COMP_CWORD]}
  132   prev=${COMP_WORDS[COMP_CWORD-1]}
  133 
  134   case "$prev" in
  135     --help|-h)
  136       	return 0
  137       ;;
  138     --version|-v)
  139     	return 0
  140   esac
  141 
  142   if [[ $cur == -* ]]; then
  143 	  COMPREPLY=( $( compgen -W "$( pkgmk --help | awk '/--/ { printf "%2s ", $2 }' )" -- $cur ) ) 
  144   else
  145 	COMPREPLY=( $( compgen -f -X '!*.pkg.tar.gz' -- $cur ) $( compgen -d -- $cur ) )
  146   fi
  147   
  148   
  149 }
  150 complete -F _pkgadd -o filenames pkgadd
  151 
  152 #ports completion
  153 _ports ()
  154 {
  155   local cur prev
  156   COMPREPLY=()
  157   cur=${COMP_WORDS[COMP_CWORD]}
  158   prev=${COMP_WORDS[COMP_CWORD-1]}
  159 
  160 
  161   case "$prev" in
  162     --help|-h)
  163       	return 0
  164       ;;
  165     --version|-v)
  166     	return 0
  167 	;;
  168     --diff|-d)
  169     	return 0
  170 	;;
  171     --list|-l)
  172     	return 0
  173 	;;
  174     --update|-u)
  175     	return 0
  176 	;;
  177   esac
  178   
  179   COMPREPLY=( $( compgen -W "$( ports --help | awk '/--/ { printf "%2s ", $2 }' )" -- $cur ) ) 
  180 }
  181 complete -F _ports ports

Generated by cgit