cdd : add autocomplete.
This commit is contained in:
parent
5bfccdbcce
commit
5a2ccd5f39
|
@ -12,11 +12,6 @@ function cdd() {
|
||||||
shopt -s nocasematch
|
shopt -s nocasematch
|
||||||
|
|
||||||
# Find desired dir.
|
# Find desired dir.
|
||||||
# for dir in "${array[@]}"; do
|
|
||||||
# result="${result}/${dir}"
|
|
||||||
# [[ "${dir}" =~ "${target}" ]] && break
|
|
||||||
# done
|
|
||||||
|
|
||||||
local found=1
|
local found=1
|
||||||
for (( idx=${#array[@]}-2 ; idx>=0 ; idx-- )); do
|
for (( idx=${#array[@]}-2 ; idx>=0 ; idx-- )); do
|
||||||
dir="${array[idx]}"
|
dir="${array[idx]}"
|
||||||
|
@ -35,3 +30,13 @@ function cdd() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cdd_directories() {
|
||||||
|
local array
|
||||||
|
IFS='/' read -r -a array <<< "${PWD}"
|
||||||
|
array=("${array[@]:1}")
|
||||||
|
unset array[-1]
|
||||||
|
_autocomplete_first "${array[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -o nosort -o filenames -F _cdd_directories cdd
|
||||||
|
|
Reference in a new issue