Files
bash-it/themes
Brian Malehorn 2a3fde2b14 colors.theme.bash: pre-compute colors
bash-it takes rather a while to startup, around 0.5 seconds on my
laptop. After a bit of timing it appears the majority of the time is
spent in themes/colors.theme.bash. The reason for that is the fancy
abstraction layers that use $(). For example, consider this code:

    red="$(color reset red)"

It will go through 9 forkexecs to evaluate:

    red="$(color reset red)"
        "$(__color_parse make_ansi reset red)"
        "$(__make_ansi reset red)"
        "\[\e[$(__reset red)m\]"
        "\[\e[0;$(__red)m\]"
        "\[\e[0;$(__color red)m\]"
        "\[\e[0;$(__color_normal_fg $(__color_red))m\]"
        "\[\e[0;$(__color_normal_fg 1)m\]"
        "\[\e[0;31m\]"

With all the variables in colors.theme.bash, this adds up to hundreds of
forks:

    $ strace -f bash ./colors.theme.bash 2>&1 | grep clone | wc -l
    649

The solution is to replace the function with its result:

    -red="$(color reset red)"
    +red='\[\e[0;31m\]'

This is safe, since colors.theme.bash never calls external functions or
takes any input. So, its result can be safely hard-coded.

This improves startup time dramatically. Try adding "time" to your .bashrc:

    # Load Bash It
    time source $BASH_IT/bash_it.sh

before:

    real    0m0.462s
    user    0m0.100s
    sys     0m0.399s

after:

    real    0m0.150s
    user    0m0.091s
    sys     0m0.064s
2016-04-09 20:52:47 -07:00
..
2013-08-20 21:46:09 +02:00
2015-09-06 12:22:48 +02:00
2015-08-03 02:53:35 -04:00
2011-04-29 17:56:04 -05:00
2012-05-01 17:25:47 -05:00
2015-08-02 12:18:35 +03:00
2014-02-20 13:07:33 +02:00
2012-04-17 00:24:58 -04:00
2012-12-15 00:04:11 -08:00
2016-01-01 16:29:26 +08:00
2012-04-17 00:24:58 -04:00
2012-04-17 00:24:58 -04:00
2015-08-31 16:36:07 -07:00
Fix
2015-11-27 01:41:19 +09:00
2014-12-08 13:39:38 +01:00
2015-07-21 23:29:22 +05:30
2011-11-12 01:10:24 -07:00
2015-09-07 01:43:40 -03:00
2014-10-28 11:39:39 -02:00
2012-04-17 00:24:58 -04:00
2012-04-17 00:24:58 -04:00
2015-12-19 23:37:12 -05:00