异步加载 bash_completion 脚本
我的 .bash_profile
脚本中的 bash_completion
脚本运行缓慢,导致新终端启动速度非常慢。是否可以提供一个用于运行命令的 shell,然后在后台获取 bash_completion 脚本?
The bash_completion
script in my .bash_profile
script is running slowly, making new terminals very slow to start up. Is it possible to present a shell for running commands, and then source the bash_completion script in the background?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不这么认为,bash_completion 取决于设置的一些变量,如果您尝试在后台加载它们(使用
&
),它们将在子 shell 上创建,并且在你正在运行的外壳。但是,您可以将它们从 .bashrc 移至 .bash_profile,然后注销,这样每个会话仅加载一次,但我不确定这是否有效,因为其中大多数是数组,而且据我所知,它们无法导出。
我想你也可以尝试某种“缓存”,虽然很丑陋,但可能会加速一点。
I don't think so, bash_completion depends on some variables being set and if you try to load them on the background (with
&
) they'll be created on a subshell and not be available on the shell you're runnning.you can however move those from .bashrc to .bash_profile and then logout, that way they're loaded only once per session but I'm not sure if this would work either since most of those are arrays and afaik those can't be exported.
I suppose you could also try some kind of "caching" that will be ugly but may speed up a bit.