contrib/bash_completion
changeset 1587 851bc33ff545
parent 1556 561b17b7d3a2
child 1638 1c75487badd6
equal deleted inserted replaced
1586:5c5aaaa9ab6f 1587:851bc33ff545
    25 
    25 
    26 _hg_paths()
    26 _hg_paths()
    27 {
    27 {
    28     local paths="$(hg paths | sed -e 's/ = .*$//')"
    28     local paths="$(hg paths | sed -e 's/ = .*$//')"
    29     COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$paths" -- "$cur" ))
    29     COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$paths" -- "$cur" ))
       
    30 }
       
    31 
       
    32 _hg_repos()
       
    33 {
       
    34     local i
       
    35     for i in $( compgen -d -- "$cur" ); do
       
    36         test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i")
       
    37     done
    30 }
    38 }
    31 
    39 
    32 _hg_status()
    40 _hg_status()
    33 {
    41 {
    34     local files="$( hg status -$1 | cut -b 3- )"
    42     local files="$( hg status -$1 | cut -b 3- )"
    90     fi
    98     fi
    91 
    99 
    92     # global options
   100     # global options
    93     case "$prev" in
   101     case "$prev" in
    94 	-R|--repository)
   102 	-R|--repository)
    95 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
   103 	    _hg_repos
    96 	    return
   104 	    return
    97 	;;
   105 	;;
    98 	--cwd)
   106 	--cwd)
    99 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
   107 	    # Stick with default bash completion
   100 	    return
   108 	    return
   101 	;;
   109 	;;
   102     esac
   110     esac
   103 
   111 
   104     if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
   112     if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
   121 	export|manifest|update)
   129 	export|manifest|update)
   122 	    _hg_tags
   130 	    _hg_tags
   123 	;;
   131 	;;
   124 	pull|push|outgoing|incoming)
   132 	pull|push|outgoing|incoming)
   125 	    _hg_paths
   133 	    _hg_paths
   126 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
   134 	    _hg_repos
   127 	;;
   135 	;;
   128 	paths)
   136 	paths)
   129 	    _hg_paths
   137 	    _hg_paths
   130 	;;
   138 	;;
   131 	add)
   139 	add)
   149 	clone)
   157 	clone)
   150 	    local count=$(_hg_count_non_option)
   158 	    local count=$(_hg_count_non_option)
   151 	    if [ $count = 1 ]; then
   159 	    if [ $count = 1 ]; then
   152 		_hg_paths
   160 		_hg_paths
   153 	    fi
   161 	    fi
   154 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
   162             _hg_repos
   155 	;;
   163 	;;
   156 	debugindex|debugindexdot)
   164 	debugindex|debugindexdot)
   157 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.i" -- "$cur" ))
   165 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.i" -- "$cur" ))
   158 	;;
   166 	;;
   159 	debugdata)
   167 	debugdata)