Modular profile file for your shell
Dec 21, '01 07:20:12PM
Contributed by: dlandrith
This tip is a shell setup technique that I have stolen from Mandrake Linux. It is only good for people that have heavilly customized their /etc/profile file, so the instructions assume a good deal of terminal knowledge. Instead of having one, monolithic profile file that is littered with different commands and environment settings, you can modularize it into a bunch of tidy, discrete items. You can do this as follows:
- su to root and cd to the /etc directory.
- Create a directory in /etc called profile.d.
- Use your favorite console text editor to add the following lines to the beginning of your profile file:
for PROFILE_SCRIPT in $( ls /etc/profile.d/*.sh ); do
. $PROFILE_SCRIPT
done
- Convert all of the commands in your profile file to individual shell scripts, and save them in /etc/profile.d (make sure they end in .sh), and delete them from /etc/profile.
Voila! Instead of having one, confusing, hard to navigate profile file, you have tidy, individual scripts. For example, my alias for ll (I use bash, so that ll is not built in) is in /etc/profile.d/alias_ll.sh, and my prompt code is in /etc/profile.d/prompt.sh.
Comments (2)
Mac OS X Hints
http://hints.macworld.com/article.php?story=20011221192012445