You are not logged in.
Hi archers,
My .bashrc file becomes filled of many useful functions. It's kinda messy and I don't think this is very clean. I wonder if I could add these functions to a separate file.
Actually I know how to do the trick but what about speed?
Does it take more time to load a bashrc with many functions or include a separate file in the bashrc?
For you, what is the best thing (cleaner & faster as the title says)?
Thank you.
Offline
You could always split them out, source .bash_functions and do some benchmarking yourself...
My guess is that the difference will be in time intervals so small that only Spiderman will be able to notice.
Offline
You might not always need all the functions you have in your .bashrc in every session, so it can be a waste of time to load them on every session needlessly.
I don't think it practically makes a difference whether you keep them external or include them in your .bashrc.
/usr/local/bin should be first in your path by default, put all your functions there as scripts. You don't need the extension if you have a shebang so you can keep the names clean.
Offline
Or an option somehere in the middle so they can all be in one file but don't need to be source until used.
One script something like the following:
#!/bin/bash
first_cool_function() {
# do stuff here
# and here
}
second_cool_function() {
# do other stuff
}
# more functions here
$(basename $0) $@
then make a link to it for each function name.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
/usr/local/bin should be first in your path by default, put all your functions there as scripts.
I prefer $HOME/bin - this is user stuff after all, no need to stick it in a system dir.
Offline
initbox wrote:/usr/local/bin should be first in your path by default, put all your functions there as scripts.
I prefer $HOME/bin - this is user stuff after all, no need to stick it in a system dir.
Yes but than ~/.local{bin,lib,share} woud be better.
Linux odin 3.13.1-pf #1 SMP PREEMPT Wed Mar 5 21:47:28 CET 2014 x86_64 GNU/Linux
Offline
For you, what is the best thing (cleaner & faster as the title says)?
Yes, see my sig.
Last edited by graysky (2012-11-20 22:57:52)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
@graysky: Actually, I saw your sig in one of your previous message and I visited your repo. That's why I created this subject.
I found interesting things. You seem to use two different shells, so adding aliases and funtions in separate files, is for me perfect.
It's not redundant. You dont need to add functions to both zshrc and bashrc.
I "benchmarked" my bashrc with "time" command. With the functions included in an other file, it doesn't really change.
@Thaodan: I have a $HOME/.bin folder added to $PATH for all my scripts. Using $HOME/.local{bin,lib,share} isn't very necessary. I don't use user specific libs since Arch provides me everything I need.
Last edited by Ypnose (2012-11-21 11:29:32)
Offline