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
..
axin Delete the execss function, modify the note and the shown style 2015-08-24 09:10:09 +08:00
bakke Add Bakke theme 2013-08-20 21:46:09 +02:00
binaryanomaly New binaryanomaly theme 2015-09-06 12:22:48 +02:00
bobby clock_check added, datetime added instaed of clock, also battery_percentage added 2015-08-12 22:59:18 +05:30
bobby-python Modified version of the bobby theme which shows Python version, Virtualenv directory and Conda environment name. 2015-06-06 10:51:35 +01:00
brunton updated brunton theme to use battery_charge 2014-11-13 09:17:04 +00:00
candy Remove the color escape which mess up long command line in candy theme 2012-04-29 15:13:30 +02:00
clean Convert themes and plugins to use the update colors. Themes are no longer burdened with escaping the unprintable characters 2011-06-17 19:45:21 -04:00
cupcake adding cupcake theme 2015-08-03 02:53:35 -04:00
demula Check that battery plugin is enabled before calling battery functions in demula theme 2013-08-31 16:23:38 +02:00
dos Added dos theme 2011-04-29 17:56:04 -05:00
doubletime optimize this a bit 2012-05-01 17:25:47 -05:00
doubletime_multiline Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
doubletime_multiline_pyonly Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
dulcie Dulcie theme upgrades 2015-08-02 12:18:35 +03:00
duru fix wordings 2014-02-20 13:07:33 +02:00
emperor Emperor theme; features time on the prompt with different colors for each quater of the hour 2015-04-07 15:52:30 -05:00
envy Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
hawaii50 Change name of ip function to remove masking of ip command in bash 2014-08-20 12:28:17 +02:00
iterate Don't repeat the prompt if it hasn't changed 2014-08-20 09:54:52 +12:00
luan Added custom theme 2012-12-15 00:04:11 -08:00
mbriggs Add new ruby_version_prompt to mbriggs theme 2012-01-27 12:35:57 +01:00
minimal Move minimal-git theme into minimal theme 2011-06-25 11:50:56 -05:00
modern Convert themes and plugins to use the update colors. Themes are no longer burdened with escaping the unprintable characters 2011-06-17 19:45:21 -04:00
modern-t Convert themes and plugins to use the update colors. Themes are no longer burdened with escaping the unprintable characters 2011-06-17 19:45:21 -04:00
morris add host info in titlebar 2016-01-01 16:29:26 +08:00
n0qorg Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
nwinkler Added custom bash prompt, based on the 'my' theme. 2013-11-07 14:08:42 +01:00
pete Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
powerline Check VIMRUNTIME instead 2015-08-31 16:36:07 -07:00
powerline-multiline Adding support for rbenv in addition to rvm 2016-03-14 03:25:32 -07:00
powerline-naked Added Powerline-naked theme 2015-01-06 23:57:11 +01:00
powerline-plain Changed default value to true for SCM_GIT_SHOW_DETAILS 2015-01-06 12:57:57 +01:00
primer Added Primer (minimal time) theme, based off of the candy theme. 2016-01-13 18:31:10 -08:00
pro Fix 2015-11-27 01:41:19 +09:00
pure Update pure.theme.bash 2014-12-08 13:39:38 +01:00
rainbowbrite Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
rana New Theme 2015-07-21 23:29:22 +05:30
rjorgenson fixed some syntax problems 2011-11-12 01:10:24 -07:00
roderik Added my own theme, based on gentoo's prompt 2012-12-30 15:49:58 +01:00
sexy [sexy theme] remove extra reset which finds its way into stdout 2014-03-05 21:24:59 -05:00
simple Update simple theme 2015-09-07 01:43:40 -03:00
sirup Convert themes and plugins to use the update colors. Themes are no longer burdened with escaping the unprintable characters 2011-06-17 19:45:21 -04:00
slick added: slick theme 2014-10-28 11:39:39 -02:00
standard Convert themes and plugins to use the update colors. Themes are no longer burdened with escaping the unprintable characters 2011-06-17 19:45:21 -04:00
tonka Added 'tonka' prompt, and personal color scheme. 2011-03-14 20:36:25 -04:00
tylenol Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
zitron Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
zork fix normal user username 2015-12-19 23:37:12 -05:00
base.theme.bash Explained `git pair` and a more reliable fallback 2016-03-16 20:15:20 -07:00
colors.theme.bash colors.theme.bash: pre-compute colors 2016-04-09 20:52:47 -07:00