/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. comp_include _filedir _get_cword
  3. _rcs()
  4. {
  5. local cur prev file dir i
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. file=${cur##*/}
  10. dir=${cur%/*}
  11. # deal with relative directory
  12. [ "$file" = "$dir" ] && dir=.
  13. COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
  14. for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  15. file=${COMPREPLY[$i]##*/}
  16. dir=${COMPREPLY[$i]%RCS/*}
  17. COMPREPLY[$i]=$dir$file
  18. done
  19. COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
  20. for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  21. COMPREPLY[$i]=${COMPREPLY[$i]%,v}
  22. done
  23. # default to files if nothing returned and we're checking in.
  24. # otherwise, default to directories
  25. [ ${#COMPREPLY[@]} -eq 0 -a "$1" = ci ] && _filedir || _filedir -d
  26. } # _rcs()