It's also remarkably fast because I took great effort to optimize the parts that happen the most. Shell is actually pretty fast if you don't fork and exec all the time...
Well, it's about 400 lines total. Roughly 40% of that is PATH handling functions: add_to, append_to, replace_in, remove_from, prefix and unprefix. They're used like:
add_to PATH /usr/sbin
prefix and unprefix are a macro for a bunch of standard replace_in/remove_froms:
...All of which are managed by different package managers (stow, brew, ports).
All that stuff is the part I optimized so that it only uses bash built-ins and never execs. Converting that away from sed/perl shaved about 8 seconds off my startup time (it's now so fast I don't notice it).
The next 20% is interactive stuff. Setting up the prompt, aliases, stty, etc. This is generally more complicated than it technically needs to be because it's cross platform so it'll run on any unix-y thing with no changes.
Then remaining 40% is a big chunk of shell functions that are mostly unused in my day-to-day life, but kept there to jog my memory if I need to do a certain task.
That adds up to 100%, but it's also worth noting that 27% of that is blank lines and comments.
Comments
I just checked, for fun:
Yep.It's also remarkably fast because I took great effort to optimize the parts that happen the most. Shell is actually pretty fast if you don't fork and exec all the time...
What do you have in it that takes up so much space? FYI: I'm not being argumentative, I am genuinely curious.
Well, it's about 400 lines total. Roughly 40% of that is PATH handling functions: add_to, append_to, replace_in, remove_from, prefix and unprefix. They're used like:
prefix and unprefix are a macro for a bunch of standard replace_in/remove_froms: So that later I can do stuff like: ...All of which are managed by different package managers (stow, brew, ports).All that stuff is the part I optimized so that it only uses bash built-ins and never execs. Converting that away from sed/perl shaved about 8 seconds off my startup time (it's now so fast I don't notice it).
The next 20% is interactive stuff. Setting up the prompt, aliases, stty, etc. This is generally more complicated than it technically needs to be because it's cross platform so it'll run on any unix-y thing with no changes.
Then remaining 40% is a big chunk of shell functions that are mostly unused in my day-to-day life, but kept there to jog my memory if I need to do a certain task.
That adds up to 100%, but it's also worth noting that 27% of that is blank lines and comments.