Load Bash quicker by deferring completion loading until the end and backgrounding

This commit is contained in:
Scott Wallace 2018-09-02 11:23:53 +01:00
parent 468207b5ac
commit 541d8de23d

17
.bashrc
View file

@ -81,11 +81,13 @@ fi
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Add bash completion scripts
# Add bash completion scripts (deferred until the end and backgrounded)
#--------------------------------------------------------------------------------
if [ -f $(brew --prefix 2>/dev/null)/etc/bash_completion ]; then
. $(brew --prefix 2>/dev/null)/etc/bash_completion
fi
function _deferred {
if [ -f $(brew --prefix 2>/dev/null)/etc/bash_completion ]; then
. $(brew --prefix 2>/dev/null)/etc/bash_completion
fi
}
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
@ -165,3 +167,10 @@ fi
#--------------------------------------------------------------------------------
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# Kick off the _deferred() function and background it (speeding up Bash loading)
#--------------------------------------------------------------------------------
trap '_deferred 2>/dev/null; trap USR1' USR1
{ sleep 0.1 ; builtin kill -USR1 $$ ; } & disown
#--------------------------------------------------------------------------------