Asynchronous loading of things in .bash_profile - is this possible?

I have these absolutely delicious bash scripts in my .bash_profile , which makes working with git on the command line really enjoyable.

 source ~/dev/git-completion.bash source ~/dev/git-flow-completion.bash 

The only problem is that it requires a lot of disk I / O (and some processor) to work. Every time I cd to the git repo directory (on a disk without a disk), an annoying delay occurs, which can sometimes last several seconds.

9/10 times I do not need the information in the prompt immediately. Often I just want to start a terminal, do something and close it.

Is it possible to run it as a background task? That is, asynchronously. In this way, a heavy blocking of I / O can be done while I am doing something else. If I need it right after opening the terminal, I will wait with pleasure. Like I have to do today.

The dream will be something like this:

 source --async ~/dev/git-completion.bash source --async ~/dev/git-flow-completion.bash 
+4
source share
1 answer

What do scripts do? Do they set environment variables or do they make some data on the disk that is independent of the environment?

If the first, then probably luck will succeed: I do not consider it possible to run the script asynchronously and affect the current environment. If the latter, then you just tried to do ~/dev/git-completion.bash & ?

+1
source

Source: https://habr.com/ru/post/1380835/


All Articles