Bash 自动完成功能有时会变得缓慢/冻结。光标停止闪烁 1-2 秒,然后自动完成功能开始打印。某些目录会发生这种情况。例如,我有一个项目目录
cd ~/proj 不会导致速度变慢或冻结 cd ~/ 确实会导致速度暂时冻结或变慢。我安装了 zsh 和不似乎面临同样的问题。
这是我的 $PATH
/home/benjamin/.local/bin:在/usr/local/sbin:在/usr/local/bin:在/usr/sbin:在/usr/bin:/sbin:/bin:/snap/bin
当我在调试模式下运行 bash 时,我得到以下输出:
+ _init_completion
+ local exclude= flag outx errx inx OPTIND=1
+ getopts n:e:o:i:s flag
+ COMPREPLY=()
+ local 'redir=@(?([0-9])<|?([0-9&])>?(>)|>&)'
+ _get_comp_words_by_ref -n '<>&' cur prev words cword
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n '<>&' cur prev words cword
+ case $flag in
+ exclude='<>&'
+ getopts c:i:n:p:w: flag -n '<>&' cur prev words cword
+ [[ 6 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ let 'OPTIND += 1'
+ [[ 6 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ let 'OPTIND += 1'
+ [[ 6 -ge 5 ]]
+ case ${!OPTIND} in
+ vwords=words
+ let 'OPTIND += 1'
+ [[ 6 -ge 6 ]]
+ case ${!OPTIND} in
+ vcword=cword
+ let 'OPTIND += 1'
+ [[ 6 -ge 7 ]]
+ __get_cword_at_cursor_by_ref '<>&' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '<>&' words cword
+ local exclude i j line ref
+ [[ -n <>& ]]
+ exclude='<>&'
+ printf -v cword %s 1
+ [[ -n <>& ]]
+ line='cd ~/'
+ (( i=0, j=0 ))
+ (( i < 2 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ printf -v 'words[0]' %s cd
+ line=' ~/'
+ [[ 0 == 1 ]]
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 1 -gt 0 ]]
+ [[ ~/ == +([<>&]) ]]
+ ref='words[1]'
+ printf -v 'words[1]' %s '~/'
+ line=
+ [[ 1 == 1 ]]
+ printf -v cword %s 1
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 2 == 1 ]]
+ local i cur index=5 'lead=cd ~/'
+ [[ 5 -gt 0 ]]
+ [[ -n cd ~/ ]]
+ [[ -n cd~/ ]]
+ cur='cd ~/'
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 5 -ge 2 ]]
+ [[ cd != \c\d ]]
+ [[ 0 -lt 1 ]]
+ local old_size=5
+ cur=' ~/'
+ local new_size=3
+ index=3
+ (( ++i ))
+ (( i <= cword ))
+ [[ 3 -ge 2 ]]
+ [[ ~ != \~\/ ]]
+ cur='~/'
+ [[ 3 -gt 0 ]]
+ (( index-- ))
+ [[ 2 -ge 2 ]]
+ [[ ~/ != \~\/ ]]
+ [[ 1 -lt 1 ]]
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n ~/ ]]
+ [[ ! -n ~/ ]]
+ [[ 2 -lt 0 ]]
+ local words cword cur
+ _upvars -a2 words cd '~/' -v cword 1 -v cur '~/'
+ (( 10 ))
+ (( 10 ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur='~/'
+ shift 3
+ (( 0 ))
+ [[ -n cur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -n cword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -n prev ]]
+ [[ 1 -ge 1 ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -n words ]]
+ upvars+=("$vwords")
+ upargs+=(-a${#words[@]} $vwords "${words[@]}")
+ (( 4 ))
+ local cur cword prev words
+ _upvars -v cur '~/' -v cword 1 -v prev cd -a2 words cd '~/'
+ (( 13 ))
+ (( 13 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur='~/'
+ shift 3
+ (( 10 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ (( 7 ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
++ prev=cd
+ shift 3
+ (( 4 ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ (( 0 ))
+ _variables
+ [[ ~/ =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]
+ [[ ~/ =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]
+ [[ ~/ =~ ^\$\{[#!]?[A-Za-z0-9_]*\[.*]$ ]]
+ case $prev in
+ return 1
+ [[ ~/ == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ cd == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i=1 ))
+ (( i < 2 ))
+ [[ ~/ == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=2
+ (( 1 ))
+ (( i < 2 ))
+ [[ 1 -le 0 ]]
+ prev=cd
+ [[ -n '' ]]
+ return 0
+ local 'IFS=
' i j k
+ compopt -o filenames
+ [[ -z '' ]]
+ _filedir -d
+ local 'IFS=
'
+ _tilde '~/'
+ local result=0
+ [[ ~/ == \~* ]]
+ [[ ~/ != */* ]]
+ return 0
+ local -a toks
+ local x tmp
++ compgen -d -- '~/'
+ x='~/.kite
~/Desktop
~/.pki
~/.gnupg
~/Postman
~/.config
~/.cache
~/snap
~/.mozilla
~/Pictures
~/.local
~/Templates
~/Downloads
~/.nv
~/.java
~/.vscode
~/.oracle_jre_usage
~/.gnome
~/.psensor
~/.mono
~/Public
~/Music
~/.ssh
~/projects
~/Videos
~/.pylint.d
~/Documents'
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ [[ -d != -d ]]
+ [[ 27 -ne 0 ]]
+ compopt -o filenames
+ COMPREPLY+=("${toks[@]}")
+ return
上面的调试有什么问题吗?