1
我完全按照http://zshwiki.org/home/examples/zleiab的說明操作。但是當我推動空間時,什麼都不會發生。沒有錯誤信息。縮寫不適用於zsh
很高興有一個替代方案或任何可能出現問題的想法。
我的.zshrc的全文:
setopt extendedglob
typeset -Ag abbreviations
abbreviations=(
"ac" "ack -C 5__CURSOR__--ignore-dir=.build"
"Ii" "Hello__CURSOR__! How are you"
"Im" "| more"
"Ia" "| awk"
"Ig" "| grep"
"Ieg" "| egrep"
"Iag" "| agrep"
"Igr" "| groff -s -p -t -e -Tlatin1 -mandoc"
"Ip" "| $PAGER"
"Ih" "| head"
"Ik" "| keep"
"It" "| tail"
"Is" "| sort"
"Iv" "| ${VISUAL:-${EDITOR}}"
"Iw" "| wc"
"Ix" "| xargs"
)
magic-abbrev-expand() {
local MATCH
LBUFFER=${LBUFFER%%(#m)[_a-zA-Z0-9]#}
command=${abbreviations[$MATCH]}
LBUFFER+=${command:-$MATCH}
if [[ "${command}" =~ "__CURSOR__" ]]
then
RBUFFER=${LBUFFER[(ws:__CURSOR__:)2]}
LBUFFER=${LBUFFER[(ws:__CURSOR__:)1]}
else
zle self-insert
fi
}
no-magic-abbrev-expand() {
LBUFFER+=' '
}
zle -N magic-abbrev-expand
zle -N no-magic-abbrev-expand
bindkey " " magic-abbrev-expand
bindkey "^x " no-magic-abbrev-expand
bindkey -M isearch " " self-insert
您與if語句做了一些補充,你有沒有嘗試沒有你變化? – GiftZwergrapper