Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load bash_completion script asynchronously

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?

like image 743
Kevin Burke Avatar asked May 26 '26 05:05

Kevin Burke


1 Answers

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.

like image 156
Samus_ Avatar answered May 28 '26 00:05

Samus_