ZSH自动完成git需要大量的时间,我可以关闭它或优化它吗? [英] ZSH auto completion for git takes significant amount of time, can I turn it off or optimize it?

查看:168
本文介绍了ZSH自动完成git需要大量的时间,我可以关闭它或优化它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git的tab自动完成功能对于小型项目非常有用,但是我目前正在研究两个使用git的大型项目,而且这些项目比没有用的更糟糕。每当我输入时,比如 git add forms< tab> ,git需要20秒或更长的时间才能找到文件(在本例中为forms.py),并且在这个时间范围内我无法在终端中做任何其他事情。有没有办法关闭自动完成功能,或以某种方式使其更快?

解决方案

这不是git自动完成文件名,这是你的外壳。在做例如你有没有同样的延迟猫形式< tab>?



看看这个帖子有类似的问题:

http://talkings.org/post/5236392664/zsh-and-slow-git-completion



这篇文章建议将以下内容添加到您的.zshrc中:

  __ git_files(){
_wanted files expl'local files'_files
}

编辑:这是该帖子的原始文本


我发现很多帖子都是关于git
自动完成可以在大型仓库中。有许多
建议的补丁和建议来加载最新的zsh。也许这些东西中的一个
可以工作,但我真正想要的是
完成分支和文件的名称,因为它们在
文件系统中。我没有找到任何关于如何获得这种行为的建议,所以
我想我自己。我想我会分享任何人谁可能从中受益的

  __ git_files(){
_wanted files expl 'local files'_files}

现在我可以运行git命令并获得即时完成,同时还有
获得类似于ls将提供的文件完成。



Git's tab autocompletion is useful for small projects, but I'm currently working on two big projects that use git and for these it's worse than useless. Whenever I type, say, git add forms<tab>, git takes 20 seconds or more to find the file (in this example, forms.py), and in this timespan I can't do anything else in the terminal. Is there any way to turn off the autocompletion feature, or somehow make it faster?

解决方案

It's not git auto completing the file names, it's your shell. Do you have the same delay when doing e.g. "cat forms< tab >"?

Check out this post with similar problems:

http://talkings.org/post/5236392664/zsh-and-slow-git-completion

This post suggests adding the following to your .zshrc:

__git_files () { 
    _wanted files expl 'local files' _files     
}

EDIT: Here's the original text of that post

I found many posts relating complaints about how painfully slow git auto-completion can be in large repositories. There were various suggested patches and suggestions to load the latest zsh. Maybe one of those things would work, but all I really want is for it to complete the names of branches and files as they are in the file system. I did not find any suggestions on how to get this behavior so I figured it out for myself. I thought I would share this for anyone who might benefit from it. I just added the following to my .zshrc file:

__git_files () { 
    _wanted files expl 'local files' _files  }

Now I can run git commands and get near instant completion while still getting file completion similar to what ls would provide.

这篇关于ZSH自动完成git需要大量的时间,我可以关闭它或优化它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆