44 lines
1007 B
Plaintext
Raw Normal View History

2009-05-27 18:45:51 +02:00
# bash completion for rcs
have rcs &&
_rcs()
{
2009-10-04 19:42:50 +02:00
local cur prev file dir i
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=()
_get_comp_words_by_ref cur prev
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
file=${cur##*/}
dir=${cur%/*}
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
# deal with relative directory
[ "$file" = "$dir" ] && dir=.
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
file=${COMPREPLY[$i]##*/}
dir=${COMPREPLY[$i]%RCS/*}
COMPREPLY[$i]=$dir$file
done
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[$i]=${COMPREPLY[$i]%,v}
done
2009-05-27 18:45:51 +02:00
2009-10-04 19:42:50 +02:00
# default to files if nothing returned and we're checking in.
# otherwise, default to directories
[[ ${#COMPREPLY[@]} -eq 0 && $1 == ci ]] && _filedir || _filedir -d
2009-05-27 18:45:51 +02:00
} &&
complete -F _rcs -o filenames ci co rlog rcs rcsdiff
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh