📄 ch05_03.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 5] 5.3 Setting the Terminal Type When You Log In </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:59Z"><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="ch05_01.htm"TITLE="5. Setting Up Your Terminal"><LINKREL="prev"HREF="ch05_02.htm"TITLE="5.2 The Idea of a Terminal Database "><LINKREL="next"HREF="ch05_04.htm"TITLE="5.4 Setting the TERMCAP Variable with tset "></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="ch05_02.htm"TITLE="5.2 The Idea of a Terminal Database "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.2 The Idea of a Terminal Database "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 5<BR>Setting Up Your Terminal</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_04.htm"TITLE="5.4 Setting the TERMCAP Variable with tset "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 5.4 Setting the TERMCAP Variable with tset "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7721">5.3 Setting the Terminal Type When You Log In </A></H2><PCLASS="para">If you always work at the same terminal, there's no problem with setting the terminal type explicitly in your<ACLASS="indexterm"NAME="AUTOID-4850"></A><SPANCLASS="link"><EMCLASS="emphasis">.login</EM> file (<ACLASS="linkend"HREF="ch02_02.htm"TITLE="Shell Setup Files-Which, Where, and Why ">2.2</A>)</SPAN>:</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> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">setenv TERM vt100</PRE></TD></TR></TABLE></P><PCLASS="para">or in your<SPANCLASS="link"><EMCLASS="emphasis">.profile</EM> (<ACLASS="linkend"HREF="ch02_02.htm"TITLE="Shell Setup Files-Which, Where, and Why ">2.2</A>)</SPAN>:</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 ">export</A> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">TERM=vt100; export TERM</PRE></TD></TR></TABLE></P><PCLASS="para">But if, like many UNIX users, you might log in from time to time atdifferent terminals, from home, or on different systems over a network,you need some more intelligent method for setting the terminal type.</P><PCLASS="para">It's possible to set up various kinds of<SPANCLASS="link">tests (<ACLASS="linkend"HREF="ch02_12.htm"TITLE="Automatic Setups for Different Terminals ">2.12</A>)</SPAN>in your shell setup filesto do this.<ACLASS="indexterm"NAME="AUTOID-4867"></A>But you can also do a surprising amount of terminal typetesting with <EMCLASS="emphasis">tset</EM>, even though it was nominally designed for <SPANCLASS="link">initializing the terminal (<ACLASS="linkend"HREF="ch05_11.htm"TITLE="Initializing the Terminal with tset ">5.11</A>)</SPAN>:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">If no<SPANCLASS="link">arguments (<ACLASS="linkend"HREF="ch01_02.htm"TITLE="Who Listens to What You Type? ">1.2</A>)</SPAN>are specified and <EMCLASS="emphasis">TERM</EM> is already set, <EMCLASS="emphasis">tset</EM> uses the value of <EMCLASS="emphasis">TERM</EM> to determine the terminal type.</P></LI><LICLASS="listitem"><PCLASS="para">If no arguments are specified and <EMCLASS="emphasis">TERM</EM> is <EMCLASS="emphasis">not</EM> set,then <EMCLASS="emphasis">tset</EM> uses the value specified inthe system file <EMCLASS="emphasis">/etc/ttytype</EM> or <EMCLASS="emphasis">/etc/ttys</EM>(BSD 4.3 and derivatives only).</P></LI><LICLASS="listitem"><PCLASS="para">If a terminal type is specified as an argument, that argumentis used as the terminal type, regardless of the value of <EMCLASS="emphasis">TERM</EM>.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4890"></A>The <EMCLASS="emphasis">-m</EM> (map) option allows a fine degree of control in caseswhere the terminal type may be ambiguous. For example, ifyou sometimes log in on a dialup line, sometimesover a local area network, and sometimes on a hardwiredline, the <EMCLASS="emphasis">-m</EM> option can be specified to determine which login is currently being used, and the terminal type can beset accordingly.</P></LI></UL><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4896"></A>In the Bourne shell, <EMCLASS="emphasis">tset</EM> can be used to set the value of<EMCLASS="emphasis">TERM</EM> as follows:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">TERM=`tset - -Q <CODECLASS="replaceable"><I>options</I></CODE>`; export TERM</PRE></BLOCKQUOTE></P><PCLASS="para">(Given the <EMCLASS="emphasis">-</EM> option, <EMCLASS="emphasis">tset</EM> prints the value that itdetermines for the terminal type to<SPANCLASS="link">standard output (<ACLASS="linkend"HREF="ch13_01.htm#UPT-ART-1023"TITLE="Using Standard Input and Output">13.1</A>)</SPAN>.Otherwise, it <SPANCLASS="link">initializes the terminal (<ACLASS="linkend"HREF="ch05_11.htm"TITLE="Initializing the Terminal with tset ">5.11</A>)</SPAN>,but keeps the terminal type to itself.<ACLASS="indexterm"NAME="AUTOID-4909"></A>The <EMCLASS="emphasis">-Q</EM> (quiet) option causes <EMCLASS="emphasis">tset</EM> to suppressprinting of a message it normally prints regarding thevalues to which it has set the erase and kill characters - ajob it does in its alternate role as terminal initializer.The<SPANCLASS="link">backquotes (<ACLASS="linkend"HREF="ch09_16.htm"TITLE="Command Substitution ">9.16</A>)</SPAN>surrounding the <EMCLASS="emphasis">tset</EM> command cause its output tobe interpolated into the command line.)</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4917"></A><ACLASS="indexterm"NAME="AUTOID-4920"></A>In the C shell, you should use the <SPANCLASS="link"><EMCLASS="emphasis">eval</EM> (<ACLASS="linkend"HREF="ch08_10.htm"TITLE="eval: When You Need Another Chance ">8.10</A>)</SPAN>command to capture the output of <EMCLASS="emphasis">tset</EM>; this will also allow youto<ACLASS="indexterm"NAME="AUTOID-4925"></A><SPANCLASS="link">set the <EMCLASS="emphasis">TERMCAP</EM
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -