home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 2.12 Automatic Setups for Different Terminals Chapter 2
Logging In
Next: 2.14 motd.diff: Show New Lines in Login Messages
 

2.13 A .cshrc.$HOST File for Per Host Setup

I work with different types of machines every day. It is often necessary to set things up differently for, say, a Linux box, than a SPARCstation. Going beyond that, you may want to set things up differently on a per-host basis.

I have this test in my .cshrc file:

setenv
 
if
 ~
 

setenv HOST "`uname -n`"
if (-e ~/lib/cshrc.hosts/cshrc.$HOST) then
   source ~/lib/cshrc.hosts/cshrc.$HOST
endif

So, if I log in to a machine named (50.7 ) bosco , and I have a file called ~/lib/cshrc.hosts/cshrc.bosco , I can source (44.23 ) it to customize my environment for that one machine. Examples of things you would put in a .cshrc.$HOST file:

  • Search path (8.7 ) : some machines have /usr/local/bin , and some have /opt . The same goes for cdpath (14.5 ) .

  • Terminal settings (5.9 ) : I always like to reach for the upper-right part of a keyboard to erase characters. Sometimes this is the location for the BACKSPACE key, and sometimes it is the DELETE key. I set things up so that I can consistently get "erase" behavior from whatever key is there.

  • Other shell variables (6.8 ) and environment variables (6.1 ) may be different. You may run a package on a certain machine that relies on a few environment variables. No need to always set them and use up a little bit of memory if you only use them in one place!

In general, this idea allows you to group together whatever exceptions you want for a machine, rather than having to write a series of switch (47.6 ) or if statements (47.3 ) throughout your .cshrc and .login files.

- DS


Previous: 2.12 Automatic Setups for Different Terminals UNIX Power Tools Next: 2.14 motd.diff: Show New Lines in Login Messages
2.12 Automatic Setups for Different Terminals Book Index 2.14 motd.diff: Show New Lines in Login Messages

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System