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() {
46
46
if [[ " ${compgen_opts[0]} " == -d ]]; then
47
47
mapfile -t pinyin_matched < <(
48
48
compgen -d -- |
49
+ grep -v ' ^\.\{1,2\}$' | # Exclude . and ..
49
50
bash-pinyin-completion-rs " $basepart " 2> /dev/null
50
51
)
51
52
else
52
53
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
58
62
fi
59
63
done | bash-pinyin-completion-rs " $basepart " 2> /dev/null
60
64
)
@@ -71,11 +75,7 @@ _comp_compgen_filedir() {
71
75
# merge result
72
76
local -a old_candidates=(" ${COMPREPLY[@]} " )
73
77
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]++' ) )
79
79
80
80
# fix space postfix
81
81
if (( ${# COMPREPLY[@]} == 1 )) && [[ ${COMPREPLY[0]} != * / ]]; then
You can’t perform that action at this time.
0 commit comments