File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -46,15 +46,19 @@ _comp_compgen_filedir() {
4646 if [[ " ${compgen_opts[0]} " == -d ]]; then
4747 mapfile -t pinyin_matched < <(
4848 compgen -d -- |
49+ grep -v ' ^\.\{1,2\}$' | # Exclude . and ..
4950 bash-pinyin-completion-rs " $basepart " 2> /dev/null
5051 )
5152 else
5253 mapfile -t pinyin_matched < <(
53- compgen -f -- | while IFS= read -r line; do
54- if [ -d " $line " ]; then
55- printf " %s/\n" " ${line%%/ } "
56- else
57- printf " %s\n" " $line "
54+ compgen -f -- |
55+ while IFS= read -r line; do
56+ if [[ " $line " != " ." && " $line " != " .." ]]; then # Exclude . and ..
57+ if [ -d " $line " ]; then
58+ printf " %s/\n" " ${line%%/ } "
59+ else
60+ printf " %s\n" " $line "
61+ fi
5862 fi
5963 done | bash-pinyin-completion-rs " $basepart " 2> /dev/null
6064 )
@@ -71,11 +75,7 @@ _comp_compgen_filedir() {
7175 # merge result
7276 local -a old_candidates=(" ${COMPREPLY[@]} " )
7377 COMPREPLY=(" ${old_candidates[@]} " " ${pinyin_matched[@]} " )
74-
75- # remove dup
76- IFS=$' \n ' read -r -d ' ' -a COMPREPLY < <(
77- printf ' %s\n' " ${COMPREPLY[@]} " | awk ' !seen[$0]++' | sort
78- )
78+ COMPREPLY=($( printf " %s\n" " ${COMPREPLY[@]} " | awk ' !seen[$0]++' ) )
7979
8080 # fix space postfix
8181 if (( ${# COMPREPLY[@]} == 1 )) && [[ ${COMPREPLY[0]} != * / ]]; then
You can’t perform that action at this time.
0 commit comments