PageRenderTime 104ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 63ms app.codeStats 0ms

/bash_completion_lib/complete -o filenames/rcs

http://github.com/brinkman83/bashrc
#! | 38 lines | 26 code | 12 blank | 0 comment | 0 complexity | 4c0885c00351c4a332eae73e4a67838e MD5 | raw file
 1# rcs(1) completion
 2
 3
 4comp_include _filedir _get_cword
 5
 6
 7_rcs()
 8{
 9    local cur prev file dir i
10
11    COMPREPLY=()
12    cur=`_get_cword`
13    prev=${COMP_WORDS[COMP_CWORD-1]}
14
15    file=${cur##*/}
16    dir=${cur%/*}
17
18    # deal with relative directory
19    [ "$file" = "$dir" ] && dir=.
20
21    COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
22
23    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
24        file=${COMPREPLY[$i]##*/}
25        dir=${COMPREPLY[$i]%RCS/*}
26        COMPREPLY[$i]=$dir$file
27    done
28    
29    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
30
31    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
32        COMPREPLY[$i]=${COMPREPLY[$i]%,v}
33    done
34
35    # default to files if nothing returned and we're checking in.
36    # otherwise, default to directories
37    [ ${#COMPREPLY[@]} -eq 0 -a "$1" = ci ] && _filedir || _filedir -d
38} # _rcs()