mark-directories and mark-symlinked-directories are very convenient readline
settings which append a slash to a completed directory/symlinked directory. Unfortunately, this doesn't work with directories found by looking at $CDPATH. There is now also a slash appended if the user completes on an unambiguous directory found by looking at $CDPATH. Patch by Claudio Bley <bley@CS.uni-magdeburg.de>.
This commit is contained in:
parent
7b68bd104f
commit
a1969bdd57
@ -1,6 +1,6 @@
|
||||
# bash_completion - some programmable completion functions for bash 2.05b
|
||||
#
|
||||
# $Id: bash_completion,v 1.728 2004/07/04 00:56:08 ianmacd Exp $
|
||||
# $Id: bash_completion,v 1.729 2004/07/04 01:15:29 ianmacd Exp $
|
||||
#
|
||||
# Copyright (C) Ian Macdonald <ian@caliban.org>
|
||||
#
|
||||
@ -2785,19 +2785,30 @@ _cd()
|
||||
return 0
|
||||
fi
|
||||
|
||||
IFS=$'\t\n'
|
||||
local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
|
||||
local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
|
||||
|
||||
# we have a CDPATH, so loop on its contents
|
||||
for i in ${CDPATH//:/$'\t'}; do
|
||||
# create an array of matched subdirs
|
||||
k=${#COMPREPLY[@]}
|
||||
for j in $( compgen -d $i/$cur ); do
|
||||
COMPREPLY[$k]=${j#$i/}
|
||||
k=$((++k))
|
||||
if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
|
||||
j="${j}/"
|
||||
fi
|
||||
COMPREPLY[k++]=${j#$i/}
|
||||
done
|
||||
done
|
||||
|
||||
_filedir -d
|
||||
|
||||
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
|
||||
i=${COMPREPLY[0]}
|
||||
if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
|
||||
COMPREPLY[0]="${i}/"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
if shopt -q cdable_vars; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user