📄 ch02_13.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 2] 2.13 A .cshrc.$HOST File for Per Host Setup </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:32:15Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch02_01.htm"TITLE="2. Logging In"><LINKREL="prev"HREF="ch02_12.htm"TITLE="2.12 Automatic Setups for Different Terminals "><LINKREL="next"HREF="ch02_14.htm"TITLE="2.14 motd.diff: Show New Lines in Login Messages"></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch02_12.htm"TITLE="2.12 Automatic Setups for Different Terminals "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 2.12 Automatic Setups for Different Terminals "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 2<BR>Logging In</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch02_14.htm"TITLE="2.14 motd.diff: Show New Lines in Login Messages"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 2.14 motd.diff: Show New Lines in Login Messages"BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-5570">2.13 A .cshrc.$HOST File for Per Host Setup </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-3610"></A><ACLASS="indexterm"NAME="AUTOID-3612"></A>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 wantto set things up differently on a per-host basis.</P><PCLASS="para">I have this test in my <EMCLASS="emphasis">.cshrc</EM> file:</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist"><ACLASS="co"HREF="ch06_01.htm"TITLE="6.1 What Environment Variables Are Good For ">setenv</A> <ACLASS="co"HREF="ch47_03.htm"TITLE="47.3 Conditional Statements with if ">if</A> <ACLASS="co"HREF="ch14_11.htm"TITLE="14.11 Finding (Anyone's) Home Directory, Quickly ">~</A> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">setenv HOST "`uname -n`"if (-e ~/lib/cshrc.hosts/cshrc.$HOST) then source ~/lib/cshrc.hosts/cshrc.$HOSTendif</PRE></TD></TR></TABLE></P><PCLASS="para">So, if I log in to a machine<SPANCLASS="link">named (<ACLASS="linkend"HREF="ch50_07.htm"TITLE="How UNIX Systems Remember Their Name ">50.7</A>)</SPAN><EMCLASS="emphasis">bosco</EM>, and I have a filecalled <EMCLASS="emphasis">~/lib/cshrc.hosts/cshrc.bosco</EM>, I can<SPANCLASS="link"><EMCLASS="emphasis">source</EM> (<ACLASS="linkend"HREF="ch44_23.htm"TITLE="Reading Files with the . and source Commands ">44.23</A>)</SPAN>it tocustomize myenvironment for that one machine. Examples of things you would put ina <EMCLASS="emphasis">.cshrc.$HOST</EM> file:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para"><SPANCLASS="link">Search path (<ACLASS="linkend"HREF="ch08_07.htm"TITLE="Setting Your Search Path ">8.7</A>)</SPAN>:<ACLASS="indexterm"NAME="AUTOID-3633"></A>some machines have <EMCLASS="emphasis">/usr/local/bin</EM>, and some have <EMCLASS="emphasis">/opt</EM>.The same goes for<SPANCLASS="link"><EMCLASS="emphasis">cdpath</EM> (<ACLASS="linkend"HREF="ch14_05.htm"TITLE="Saving Time When You Change Directories: cdpath ">14.5</A>)</SPAN>.</P></LI><LICLASS="listitem"><PCLASS="para"><SPANCLASS="link">Terminal settings (<ACLASS="linkend"HREF="ch05_09.htm"TITLE="Setting Your Erase, Kill, and Interrupt Characters ">5.9</A>)</SPAN>:<ACLASS="indexterm"NAME="AUTOID-3642"></A>I always like to reach for the upper-right part of a keyboardto erase characters. Sometimes this is the location for the<ACLASS="indexterm"NAME="AUTOID-3644"></A><ACLASS="indexterm"NAME="AUTOID-3647"></A>BACKSPACE key, and sometimes it is the DELETE key. I setthings up so that I can consistently get "erase" behaviorfrom whatever key is there.</P></LI><LICLASS="listitem"><PCLASS="para">Other<SPANCLASS="link">shell variables (<ACLASS="linkend"HREF="ch06_08.htm"TITLE="Shell Variables ">6.8</A>)</SPAN>and<SPANCLASS="link">environment variables (<ACLASS="linkend"HREF="ch06_01.htm#UPT-ART-1170"TITLE="What Environment Variables Are Good For ">6.1</A>)</SPAN>may be different.You may run a package on a certain machine that relieson a few environment variables. No need to always set themand use up a little bit of memory if you only use themin one place!</P></LI></UL><PCLASS="para">In general, this idea allows you to group together whatever exceptionsyou want for a machine, rather than having to write a series of<SPANCLASS="link"><EMCLASS="emphasis">switch</EM> (<ACLASS="linkend"HREF="ch47_06.htm"TITLE="Quick Reference: C Shell switch Statement ">47.6</A>)</SPAN>or<SPANCLASS="link"><EMCLASS="emphasis">if</EM> statements (<ACLASS="linkend"HREF="ch47_03.htm"TITLE="Conditional Statements with if ">47.3</A>)</SPAN>throughout your <EMCLASS="emphasis">.cshrc</EM> and <EMCLASS="emphasis">.login</EM> files.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">DS</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch02_12.htm"TITLE="2.12 Automatic Setups for Different Terminals "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 2.12 Automatic Setups for Different Terminals "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch02_14.htm"TITLE="2.14 motd.diff: Show New Lines in Login Messages"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 2.14 motd.diff: Show New Lines in Login Messages"BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">2.12 Automatic Setups for Different Terminals </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">2.14 motd.diff: Show New Lines in Login Messages</TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -