如何修复 oh-my-zsh 中 rake 自动完成的严重延迟

如何修复 oh-my-zsh 中 rake 自动完成的严重延迟

我在自动完成 rake 时遇到了严重的延迟。我有一台 2011 MBP,配有 SSD,尝试自动完成时仍然会遇到大约 3 - 5 秒的延迟。

感谢您的帮助!

.zshrc:

###OHMYZSH
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="lambda"
COMPLETION_WAITING_DOTS="true"
plugins=(node git bundler rails rails3 ruby autojump npm bower)
source $ZSH/oh-my-zsh.sh

###PATH
export PATH=/usr/local/sbin:/usr/local/bin/rbenv:/usr/local/bin:/usr/local/bin/ctags:/usr/local/postgres:/Users/chance/.rbenv/shims:/usr/local/share/zsh:$PATH
export PATH=$PATH:$HOME/.npm # Add npm modules to PATH for scripting
export PATH=$PATH:$HOME/.npm/bin # Add npm modules to PATH for scripting
export PATH=$PATH:$HOME/.npm/lib # Add npm modules to PATH for scripting


###ALIASES
  alias pg_start="pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start"
  alias pg_stop="pg_ctl -D /usr/local/var/postgres stop -s -m fast"
  alias show_hidden='defaults write com.apple.finder AppleShowAllFiles TRUE & killall Finder'
  alias hide_hidden='defaults write com.apple.finder AppleShowAllFiles FALSE & killall Finder'
  alias mw='mocha -w -s 20ms -t 1000 --reporter Spec --growl'


###PG
export PGDATA='/usr/local/pgsql/data'


###BREW
if [ -f `brew --prefix`/etc/autojump ]; then
  . `brew --prefix`/etc/autojump
fi

###HEROKU
export PATH="/usr/local/heroku/bin:$PATH"

###NPM
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
export COMP_WORDBREAKS

if type complete &>/dev/null; then
  _npm_completion () {
    local si="$IFS"
    IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
                           COMP_LINE="$COMP_LINE" \
                           COMP_POINT="$COMP_POINT" \
                           npm completion -- "${COMP_WORDS[@]}" \
                           2>/dev/null)) || return $?
    IFS="$si"
  }
  complete -F _npm_completion npm
elif type compdef &>/dev/null; then
  _npm_completion() {
    si=$IFS
    compadd -- $(COMP_CWORD=$((CURRENT-1)) \
                 COMP_LINE=$BUFFER \
                 COMP_POINT=0 \
                 npm completion -- "${words[@]}" \
                 2>/dev/null)
    IFS=$si
  }
  compdef _npm_completion npm
elif type compctl &>/dev/null; then
  _npm_completion () {
    local cword line point words si
    read -Ac words
    read -cn cword
    let cword-=1
    read -l line
    read -ln point
    si="$IFS"
    IFS=$'\n' reply=($(COMP_CWORD="$cword" \
                       COMP_LINE="$line" \
                       COMP_POINT="$point" \
                       npm completion -- "${words[@]}" \
                       2>/dev/null)) || return $?
    IFS="$si"
  }
  compctl -K _npm_completion npm
fi
###-end-npm-completion-###

答案1

我在寻找一些不相关的东西时偶然发现了这个问题,但事实证明,就在昨晚,我将一个旧脚本重新打包成一个 oh-my-zsh 插件来缓存 rake 建议并使 rake 自动完成速度更快:

https://github.com/KevinBongart/rake-fast

希望这可以帮助!

相关内容