Commit Graph

13 Commits (c86038d61d8dca831e96ab47c86d1b336d9f1fb2)

Author SHA1 Message Date
Daijiro Wachi a014282707 Fix white color in colors.theme 2017-04-10 12:01:59 +02:00
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
Hector Rivas Gandara 2360790ee3 Fix infinite loop when $PS4 calls external command
When using `set -x` with a `$PS4` variable which calls a external
command (e.g. `PS4='+ $(true)'`) the color functions end in a infite
loop.

The solution is `shift` the arguments unconditionally in the color
funtions.

This fixes #546
2015-08-12 12:00:14 +01:00
Eitan Adler 3fc60b5358 Fix bogus bash binary location 2012-04-17 00:24:58 -04:00
Beren Minor 87d7d7ad34 Fixed issue #103 caused by "normal" colors not reseting bold/underline/... text attributes. 2012-02-14 09:13:51 +01:00
Beren Minor 879d54031d Even better color framework. 2012-02-08 09:35:21 +01:00
Beren Minor 1da06a4b63 Improved color framework. 2012-02-08 00:22:40 +01:00
Travis Swicegood ae3acff27d Add echo_ prefixed colors that work with echo -e (re: #96) 2012-01-26 08:18:59 -06:00
JFSIII 46b8d27815 Change color definitions so they don't require escaping in the themes. When do you ever want those unprintable characters included in the character count? 2011-06-17 14:58:20 -04:00
Robert R Evans 45a50c099e Updated the color themes. Added underline and background colors. 2010-10-09 15:01:50 -07:00
Robert R Evans b64c228da5 Updates 2010-10-07 17:15:14 -07:00
Robert R Evans 7ca450440c Fixed issue #2 2010-10-06 18:21:46 -07:00
Robert R Evans 70c3b523b3 Added a couple more themes and put colors into its own file 2010-10-03 11:50:22 -07:00