- 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
|
# 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>
|
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||||
#
|
#
|
||||||
@ -597,25 +597,16 @@ _cvs()
|
|||||||
{
|
{
|
||||||
set_prefix()
|
set_prefix()
|
||||||
{
|
{
|
||||||
[ "$prefix" = "" ] || prefix=${cur%/*}/
|
[ -z "$prefix" ] || prefix=${cur%/*}/
|
||||||
[ -r ${prefix}CVS/Entries ] || prefix=""
|
[ -r ${prefix}CVS/Entries ] || prefix=""
|
||||||
}
|
}
|
||||||
|
|
||||||
get_entries()
|
get_entries()
|
||||||
{
|
{
|
||||||
|
|
||||||
entries=( $( cut -d/ -f2 -s ${prefix}CVS/Entries | \
|
entries=( $( cut -d/ -f2 -s ${prefix}CVS/Entries | \
|
||||||
grep "^$cur" ) )
|
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 cur count mode i cvsroot pwd
|
||||||
local -a flags miss files entries changed newremoved
|
local -a flags miss files entries changed newremoved
|
||||||
|
|
||||||
@ -672,24 +663,25 @@ _cvs()
|
|||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
add)
|
add)
|
||||||
if [[ "$cur" != -* ]] ; then
|
if [[ "$cur" != -* ]]; then
|
||||||
set_prefix
|
set_prefix
|
||||||
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
||||||
get_entries
|
get_entries
|
||||||
[ -z "$cur" ] && \
|
[ -z "$cur" ] && \
|
||||||
files=$( \ls -d ${prefix}!(CVS) ) || \
|
files=$( \ls -A | grep -v '^CVS$' ) || \
|
||||||
files=$( \ls -d ${cur}* )
|
files=$( \ls -d ${cur}* )
|
||||||
for i in ${entries[@]}; do
|
for i in ${entries[@]}; do
|
||||||
files=( ${files[@]/%$i/} )
|
files=( ${files[@]%$i} )
|
||||||
done
|
done
|
||||||
COMPREPLY=( $( compgen -W '${files[@]}' $cur ) )
|
COMPREPLY=( $( compgen -W '${files[@]}' -- \
|
||||||
|
$cur ) )
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
|
COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
admin)
|
admin)
|
||||||
if [[ "$cur" = -* ]] ; then
|
if [[ "$cur" = -* ]]; then
|
||||||
COMPREPLY=( $( compgen -W '-i -a -A -e -b -c -k -l -u \
|
COMPREPLY=( $( compgen -W '-i -a -A -e -b -c -k -l -u \
|
||||||
-L -U -m -M -n -N -o -q -I \
|
-L -U -m -M -n -N -o -q -I \
|
||||||
-s -t -t- -T -V -x -z' -- \
|
-s -t -t- -T -V -x -z' -- \
|
||||||
@ -697,13 +689,23 @@ _cvs()
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
checkout)
|
checkout)
|
||||||
if [[ "$cur" != -* ]] ; then
|
if [[ "$cur" != -* ]]; then
|
||||||
# can only do for local repositories
|
# can only do for local repositories
|
||||||
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
|
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
|
||||||
if [ -r $cvsroot ]; then
|
prefix=${cur%/*}
|
||||||
get_modules
|
[ -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=( $( compgen -W \
|
||||||
'${COMPREPLY[@]}' $cur ) )
|
'${COMPREPLY[@]}' -- $cur ) )
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
|
COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
|
||||||
@ -717,18 +719,18 @@ _cvs()
|
|||||||
# found so far, but other changes (something other than
|
# found so far, but other changes (something other than
|
||||||
# changed/removed/new) may be missing
|
# changed/removed/new) may be missing
|
||||||
changed=$( cvs diff --brief 2>&1 | \
|
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 | \
|
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[@]} \
|
COMPREPLY=( $( compgen -W '${changed[@]} \
|
||||||
${newremoved[@]}' $cur ) )
|
${newremoved[@]}' -- $cur ) )
|
||||||
else
|
else
|
||||||
COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
|
COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
|
||||||
$cur ) )
|
$cur ) )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
remove)
|
remove)
|
||||||
if [[ "$cur" != -* ]] ; then
|
if [[ "$cur" != -* ]]; then
|
||||||
set_prefix
|
set_prefix
|
||||||
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
if [ $COMP_CWORD -gt 1 -a -r ${prefix}CVS/Entries ]; then
|
||||||
get_entries
|
get_entries
|
||||||
@ -736,25 +738,31 @@ _cvs()
|
|||||||
for i in ${entries[@]}; do
|
for i in ${entries[@]}; do
|
||||||
[ ! -r "$i" ] && miss=( ${miss[@]} $i )
|
[ ! -r "$i" ] && miss=( ${miss[@]} $i )
|
||||||
done
|
done
|
||||||
COMPREPLY=( $( compgen -W '${miss[@]}' $cur ) )
|
COMPREPLY=( $(compgen -W '${miss[@]}' -- $cur) )
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
|
COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
import)
|
import)
|
||||||
if [[ "$cur" != -* ]] ; then
|
if [[ "$cur" != -* ]]; then
|
||||||
# starts with same algorithm as checkout
|
# starts with same algorithm as checkout
|
||||||
[ -z "$cvsroot" ] && cvsroot=$CVSROOT
|
[ -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 )
|
||||||
pwd=${pwd##*/}
|
pwd=${pwd##*/}
|
||||||
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' $cur ))
|
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
|
||||||
|
$cur ) )
|
||||||
else
|
else
|
||||||
COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
|
COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
"")
|
||||||
COMPREPLY=( $( compgen -W 'add admin checkout ci co commit \
|
COMPREPLY=( $( compgen -W 'add admin checkout ci co commit \
|
||||||
diff delete export freeze get \
|
diff delete export freeze get \
|
||||||
history import log new patch rcs \
|
history import log new patch rcs \
|
||||||
@ -763,6 +771,8 @@ _cvs()
|
|||||||
-b -d -e -f -l -n -t -r -v -w -x \
|
-b -d -e -f -l -n -t -r -v -w -x \
|
||||||
-z --help --version' -- $cur ) )
|
-z --help --version' -- $cur ) )
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user