##空行(光标在行首)补全 "cd " {{{ user-complete(){ case $BUFFER in "" ) # 空行填入 "cd " BUFFER="cd " zle end-of-line zle expand-or-complete ;; cd\ \ * ) # TAB + 空格 替换为 "cd ~" BUFFER=${BUFFER/\ \ /\ ~} zle end-of-line zle expand-or-complete ;; " " ) BUFFER="z " zle end-of-line ;; "cd --" ) # "cd --" 替换为 "cd +" BUFFER="cd +" zle end-of-line zle expand-or-complete ;; "cd +-" ) # "cd +-" 替换为 "cd -" BUFFER="cd -" zle end-of-line zle expand-or-complete ;; * ) zle expand-or-complete ;; esac } zle -N user-complete bindkey "\t" user-complete user-ret(){ if [[ $BUFFER = "" ]] ;then BUFFER="ls" zle end-of-line zle accept-line elif [[ $BUFFER =~ "^cd\ \.\.\.+$" ]] ;then BUFFER=${${BUFFER//\./\.\.\/}/\.\.\//} zle end-of-line zle accept-line else zle accept-line fi } zle -N user-ret bindkey "\r" user-ret #显示 path-directories ,避免候选项唯一时直接选中 cdpath="/home" #}}}