37 lines
903 B
Plaintext
Raw Normal View History

# bash completion for rcs -*- shell-script -*-
2009-05-27 18:45:51 +02:00
_rcs()
{
local cur prev words cword
_init_completion || return
2009-05-27 18:45:51 +02:00
local file dir i
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
2011-11-09 23:28:11 +02:00
[[ $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
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 ci co rlog rcs rcsdiff
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh