There are 3 ways to distribute:
- add lines to
- a file that is sourced by
- a file that can be included into the directory
I would say it depends on the number of functions and their lengths. If it's 2 or more functions, and they are somewhat lengthy I would almost exclusively distribute them as a single file (or files) that gets sourced via either the user's
$HOME/.bashrc file or incorporated into
/etc/profile.d, via a script you provide them.
If it's a single function or perhaps 2, and they're quite short, then I would distribute them strictly as a .txt file or simply post them on github as code that is meant to be copy/pasted into your existing environment, i.e. included into
$HOME/.bashrc or a preexisting file under
/etc/profile.d, ultimately leaving it to the user where exactly.
/etc/profile.d contains files for multiple shells (Csh, Bash, Zsh, etc.). Any files included here will be used by these other shells as well. The naming of files here is what controls which shells will utilize them. A
.csh will provide for Csh/Tcsh, a
.sh for Bash, Zsh, etc.
On the proper use of
If you're curious, files added to
/etc/profile.d should contain commands that ought to only run once, at the beginning of login. (This includes graphical logins, as they start with a login shell, too.) If a shell is interactive, the user running it is probably logged on, and so it probably has an ancestor (that started it, or started what started it, or started that, etc.) that was a login shell.
See this excellent answer on AskUbuntu titled: Why is /etc/profile not invoked for non-login shells?, which details the differences between a interactive vs. login shell and their implications.