summaryrefslogblamecommitdiffstats
path: root/bash_completion
blob: edec407764f589dc327e4db0f360650a637ac63f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                                             
                                                                   






                                                                          
                       




                                    



                                                                    
 
                                                    
                                     

                                                        




                                                    

                                                         






                                   
                                                                        







                                                                               
                                                                         

                
                                                                     






                                                           
                                                                        
                  


                               

                         
                                                                                                                             


                  
             

                                                                       
             
              
                                                                        
             


                        
                                                           
                  


                                                                            

               



                       
                                                                                                           




                                                                       















                                                                                     
                                                                     





                                                                             
                                                                                     

             
                                                                                                                     






                                                           
                                                                                                  





                        
                                                                        
















                                                                               
                                                                                  


                  


                                                        


                   
                                                                        
             

                 




                                                  
 
#-*- mode: shell-script;-*-

# Programmed completion for bash to use quilt
# Copyright 2003-2004 Martin Quinson <martin.quinson@tuxfamily.org>

# This file is part of the distribution of quilt, and is distributed under
# the same licence than quilt itself

have quilt &&
_quilt()
{
    local cur prev cmds

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}

    # quilt sub commands 
    cmds='add applied delete diff edit files fold fork graph grep  \
          import new next patches pop previous push refresh remove \
	  series setup snapshot top unapplied'

    # if no command were given, complete on commands
    if [[ $COMP_CWORD -eq 1 ]] ; then
	COMPREPLY=( $( compgen -W "$cmds -h" -- $cur ) )
	return 0
    fi
	
    # if we're completing for 'quilt -h', then just 
    # complete on any valid command
    if [ ${COMP_WORDS[1]} == -h ] ; then
	    COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
            return 0
    fi
    
    # Complete depending on options
    case ${COMP_WORDS[1]} in
	add)
	   case $prev in
	     -p)
 	        COMPREPLY=( $( compgen -W "$(quilt applied)" -- $cur ) )
		;;
	     *)
	        _filedir 
	        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-p -h" -- $cur ) )
	        ;;
	   esac
	   ;;
	applied) 
	   COMPREPLY=( $( compgen -W "-n -h $(quilt applied)" -- $cur ) )
	   ;;
	delete) 
	   COMPREPLY=( $( compgen -W "-h $(quilt series)" -- $cur ) )
	   ;;
	diff) 
	   case $prev in
	     -p)
 	        COMPREPLY=( $( compgen -W "0 1" -- $cur ) )
		;;
	     -P|-c)
	     	COMPREPLY=( $( compgen -W "$(quilt applied)" -- $cur ) )
		;;
	     --diff|--snapshot)
	        COMREPLY=(  )
		;;
	     *)
	        _filedir 
	        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-p -P -c -R -z -h --snapshot --diff --no-timestamps" -- $cur ) )
	        ;;
	   esac
	   ;;
	edit)
	   _filedir
	   COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-h" -- $cur ) )
	   ;;
	files)
	   COMPREPLY=( $( compgen -W "-v -h $(quilt series)" -- $cur ) )
	   ;;
	fold)
	   case $prev in
	     -p)
	        COMPREPLY=( $( compgen -W "0 1" -- $cur ) )
		;;
	     *)
	        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-p" -- $cur ) )
	        ;;
	   esac
	   ;;
	fork)
	  COMPREPLY=( )
	  ;;
	graph)
	   COMPREPLY=( $( compgen -W "-h --all --reduce --lines --edge-labels $(quilt applied)" -- $cur ) )
	   ;;
	grep)
	   _longopt grep
	   COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-h" -- $cur ) )
	   ;;
	import)
	   case $prev in
	     -p)
 	        COMPREPLY=( $( compgen -W "0 1 2 3 4 5 6 7 8 9 10" -- $cur ) )
		;;
	     -n)
		;;
	     *)
	        _filedir 
	        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-p -n -f -h" -- $cur ) )
	        ;;
	   esac
	   ;;
	new)
	   ;;
	next|previous)
	   COMPREPLY=( $( compgen -W "-n $(quilt series)" -- $cur ) )
	   ;;
	patches)
	   _filedir 
	   COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-v -n -h" -- $cur ) )
	   ;;
	pop)
	   COMPREPLY=( $( compgen -W "-a -f -R -q -v -h $(quilt applied)" -- $cur ) )
	   ;;
	push)
	   COMPREPLY=( $( compgen -W "-a -f -R -q -v -h --leave-rejects --interactive $(quilt unapplied)" -- $cur ) )
	   ;;
	refresh)
	   case $prev in
	     -p)
 	        COMPREPLY=( $( compgen -W "0 1" -- $cur ) )
		;;
	     *)
	     	COMPREPLY=( $( compgen -W "-p -f -h $(quilt applied)  --no-timestamps" -- $cur ) )
		;;
	   esac
	   ;;
	remove)
	   case $prev in
	     -p)
 	        COMPREPLY=( $( compgen -W "$(quilt applied)" -- $cur ) )
		;;
	     *)
	        _filedir 
	        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-p -h" -- $cur ) )
		;;
	   esac
	   ;;
	 series)
	   COMPREPLY=( $( compgen -W "-n -v -h" -- $cur ) )
	   ;;
	 setup)
	   case $prev in
	     -d)
	     	_filedir -d
		;;
	     *)
	        _filedir 
	        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-d -v -h" -- $cur ) )
		;;
	   esac
	   ;;
	 snapshot)
	   COMPREPLY=( $( compgen -W "-d -h" -- $cur ) )
	   ;;
	 top)
	   ;;
	 unapplied)
	   COMPREPLY=( $( compgen -W "-n -h $(quilt series)" -- $cur ) )
	   ;;
	 upgrade)
	   ;;
    esac
    return 0
}
[ "$have" ] && complete -F _quilt $filenames quilt