- a few more changes to _cvs() from Kyle Wheeler <memoryhole@mac.com>
(e.g. cvs checkout now descends through the CVSROOT) and some code clean-up to _cvs() by me
This commit is contained in:
parent
a2d62dae9b
commit
0363d0203c
@ -1,6 +1,6 @@
|
||||
# bash_completion - some programmable completion functions for bash 2.05a
|
||||
#
|
||||
# $Id: bash_completion,v 1.169 2002/03/01 02:02:39 ianmacd Exp $
|
||||
# $Id: bash_completion,v 1.170 2002/03/01 07:58:23 ianmacd Exp $
|
||||
#
|
||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||
#
|
||||
@ -597,25 +597,16 @@ _cvs()
|
||||
{
|
||||
set_prefix()
|
||||
{
|
||||
[ "$prefix" = "" ] || prefix=${cur%/*}/
|
||||
[ -z "$prefix" ] || prefix=${cur%/*}/
|
||||
[ -r ${prefix}CVS/Entries ] || prefix=""
|
||||
}
|
||||
|
||||
get_entries()
|
||||
{
|
||||
|
||||
entries=( $( cut -d/ -f2 -s ${prefix}CVS/Entries | \
|
||||
grep "^$cur" ) )
|
||||
}
|
||||
|
||||
get_modules()
|
||||
{
|
||||
|
||||
COMPREPLY=( $( \ls -d $cvsroot/!(CVSROOT) 2>/dev/null ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]/$cvsroot/} )
|
||||
COMPREPLY=( ${COMPREPLY[@]/\//} )
|
||||
}
|
||||
|
||||
local cur count mode i cvsroot pwd
|
||||
local -a flags miss files entries changed newremoved
|
||||
|
||||
@ -677,12 +668,13 @@ _cvs()
|
||||
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
||||
get_entries
|
||||
[ -z "$cur" ] && \
|
||||
files=$( \ls -d ${prefix}!(CVS) ) || \
|
||||
files=$( \ls -A | grep -v '^CVS$' ) || \
|
||||
files=$( \ls -d ${cur}* )
|
||||
for i in ${entries[@]}; do
|
||||
files=( ${files[@]/%$i/} )
|
||||
files=( ${files[@]%$i} )
|
||||
done
|
||||
COMPREPLY=( $( compgen -W '${files[@]}' $cur ) )
|
||||
COMPREPLY=( $( compgen -W '${files[@]}' -- \
|
||||
$cur ) )
|
||||
fi
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
|
||||
@ -700,10 +692,20 @@ _cvs()
|
||||
if [[ "$cur" != -* ]]; then
|
||||
# can only do for local repositories
|
||||
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
|
||||
if [ -r $cvsroot ]; then
|
||||
get_modules
|
||||
prefix=${cur%/*}
|
||||
[ -r ${cvsroot}/${prefix} ] || prefix=""
|
||||
if [ -r ${cvsroot}/${prefix} ]; then
|
||||
if [ -n "$prefix" ]; then
|
||||
COMPREPLY=( $( \ls -d \
|
||||
${cvsroot}/${prefix}/!(CVSROOT) ) )
|
||||
else
|
||||
COMPREPLY=( $( \ls -d \
|
||||
${cvsroot}/!(CVSROOT) ) )
|
||||
fi
|
||||
COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
|
||||
COMPREPLY=( ${COMPREPLY[@]#/} )
|
||||
COMPREPLY=( $( compgen -W \
|
||||
'${COMPREPLY[@]}' $cur ) )
|
||||
'${COMPREPLY[@]}' -- $cur ) )
|
||||
fi
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
|
||||
@ -717,11 +719,11 @@ _cvs()
|
||||
# found so far, but other changes (something other than
|
||||
# changed/removed/new) may be missing
|
||||
changed=$( cvs diff --brief 2>&1 | \
|
||||
sed -ne 's/^Files [^ ]\+ and \([^ ]\+\) differ$/\1/p' )
|
||||
sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' )
|
||||
newremoved=$( cvs diff --brief 2>&1 | \
|
||||
sed -ne 's/^cvs diff: \([^ ]\+\), no comparison available$/\1/p' )
|
||||
sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' )
|
||||
COMPREPLY=( $( compgen -W '${changed[@]} \
|
||||
${newremoved[@]}' $cur ) )
|
||||
${newremoved[@]}' -- $cur ) )
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
|
||||
$cur ) )
|
||||
@ -736,7 +738,7 @@ _cvs()
|
||||
for i in ${entries[@]}; do
|
||||
[ ! -r "$i" ] && miss=( ${miss[@]} $i )
|
||||
done
|
||||
COMPREPLY=( $( compgen -W '${miss[@]}' $cur ) )
|
||||
COMPREPLY=( $(compgen -W '${miss[@]}' -- $cur) )
|
||||
fi
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
|
||||
@ -746,15 +748,21 @@ _cvs()
|
||||
if [[ "$cur" != -* ]]; then
|
||||
# starts with same algorithm as checkout
|
||||
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
|
||||
[ -r $cvsroot ] && get_modules
|
||||
if [ -r "$cvsroot" ]; then
|
||||
COMPREPLY=( $( \ls -d $cvsroot/!(CVSROOT) \
|
||||
2>/dev/null ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
|
||||
COMPREPLY=( ${COMPREPLY[@]#\/} )
|
||||
fi
|
||||
pwd=$( pwd )
|
||||
pwd=${pwd##*/}
|
||||
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' $cur ))
|
||||
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
|
||||
$cur ) )
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
"")
|
||||
COMPREPLY=( $( compgen -W 'add admin checkout ci co commit \
|
||||
diff delete export freeze get \
|
||||
history import log new patch rcs \
|
||||
@ -763,6 +771,8 @@ _cvs()
|
||||
-b -d -e -f -l -n -t -r -v -w -x \
|
||||
-z --help --version' -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user