Nov 19, '03 10:52:00AM • Contributed by: wagnerone
Many years ago a friend and I began using CVS to help organize our collaborative work. The lightbulb went on and soon after my login scripts found themselves happily residing in CVS and, therefore, on every machine I use ... in perfect sync. Ahhhh. :)
I did need a way to keep the packaged login scripts and preference files tidy and make them work with shells expecting them to be in specific locations. I chose an arbitrary directory name in my home folder (corresponding with the name of the module on the CVS server) to keep them in. I call it transport. Inside transport are versions of my various login scripts and preference files I like to keep in sync across machines (without the leading dot for editing ease). I check them out on a new machine and symlink to them from the proper, shell expected location... ie:
% cd ~wagner % ln -s transport/cshrc .cshrcI do this for my login scripts (tcsh, .login, .login, etc.), .vim, .vimrc, .xinitrc, .screenrc, and other pref files. Each time I modify one of these items, I commit those changes to the CVS server and, when I log into another machine, I update that set with the version on the CVS server. This works great for other sets of items you may want to keep in sync across machines as well. ie: maintaining all your administration scripts across machines in a similar way.
It is also pretty easy to expand a login script with conditionals to set aliases, variables, etc. based on the hostname or the flavor of OS that it's being used on. ie: I prefer to see top display information sorted on CPU use. In linux, that is the default. top -u is how you'd see that type of sorting with the default OS X top. To get a similar display on both OSs without thinking about it, I use something like this in my (tcsh) login script:
# osx stuff if (`uname` == 'Darwin') then alias top 'top -u' endifbash users could use something like:
# osx stuff if [ `uname` = "Linux" ] then alias ls='puke1' fiIf I am on a linux machine this conditional returns false and, therefore runs top with no arguments. If I am on an OS X machine, it will run top with the -u argument. You can use a hostname conditional to set up different aliases based on the host name. When I excitedly begin to explain these ideas to my friends, they tend to look at me sideways and slowly shuffle away. :) I hope some of you here can use and benefit from them and I would appreciate any suggestions or ideas on improving upon them.
Remember, your login scripts can make your life in the shell oh so much easier and more efficient! Hopefully there is a CVS primer around here somewhere...
[ robg adds: There are a couple (1, 2) older hints (very older!) that may be helpful, and then this one that talks about CVS under 10.2 -- this may be the most applicable of the bunch, though I don't know if it still works this way in Panther.]
