I need to Load RVM into a shell session as a function , so I execute this script in my zshrc.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
However, this script will slow me down about 1 seconds whenever I launch a new terminal. So I figure out a solution which put this script to background job like this:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" &
Then I got a quick launch time when I launch a new terminal. But I’ll see this message:
[1] + done source "$HOME/.rvm/scripts/rvm"
- Is there a better way to make this script don’t slow down my terminal launch time?
- how to suppress this “done” message when this background job done ?
This will not work for things like rvm. rvm relies on being able to manipulate your current shell’s environment (define its own shell functions etc). When you put a job in a background it is run in a sub-process that has no effect on the current shell. Example:
If rvm is too slow for you then you could also check out rbenv which does something similar to rvm but with much less shell magic.