⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch05_12.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 5] 5.12 Initializing the Terminal with tput </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:33:17Z"><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_11.htm"TITLE="5.11 Initializing the Terminal with tset "><LINKREL="next"HREF="ch06_01.htm"TITLE="6. Shell and Environment Variables"></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_11.htm"TITLE="5.11 Initializing the Terminal with tset "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.11 Initializing the Terminal with tset "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="CHAPTER"HREF="ch06_01.htm"TITLE="6. Shell and Environment Variables"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 6. Shell and Environment Variables"BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7924">5.12 Initializing the Terminal with tput </A></H2><PCLASS="para">The <EMCLASS="emphasis">tput</EM> program used with <EMCLASS="emphasis">terminfo</EM> is somewhat equivalent to<SPANCLASS="link"><EMCLASS="emphasis">tset</EM> (<ACLASS="linkend"HREF="ch05_03.htm"TITLE="Setting the Terminal Type When You Log In ">5.3</A>, <ACLASS="linkend"HREF="ch05_11.htm"TITLE="Initializing the Terminal with tset ">5.11</A>)</SPAN>,but does not have the ability that <EMCLASS="emphasis">tset</EM>has to determine the terminal type. On the other hand,itallows you to pick out particular terminal capabilities andprint out their values or store them into shell variables.[The<SPANCLASS="link"><EMCLASS="emphasis">tcap</EM> (<ACLASS="linkend"HREF="ch41_10.htm"TITLE="Using terminfo Capabilities in Shell Programs ">41.10</A>)</SPAN>program does the same kind of thing for <EMCLASS="emphasis">termcap</EM>. <EMCLASS="emphasis">-JP</EM>&nbsp;]This allows shell programs to<SPANCLASS="link">make use of terminal capabilities (<ACLASS="linkend"HREF="ch41_10.htm"TITLE="Using terminfo Capabilities in Shell Programs ">41.10</A>)</SPAN>such as inverse video or underlining.</P><PCLASS="para">By default, <EMCLASS="emphasis">tput</EM> assumes that you are using theterminal type specified by the<SPANCLASS="link"><EMCLASS="emphasis">TERM</EM> (<ACLASS="linkend"HREF="ch05_10.htm"TITLE="Finding What Terminal Names You Can Use ">5.10</A>)</SPAN>variable.If you wantto override the value of <EMCLASS="emphasis">TERM</EM>, you can specify anotherterminal type with the <EMCLASS="emphasis">-T</EM> option. For example:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>tput -Twy50 ...</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">&#13;In System V Release 3, <EMCLASS="emphasis">tput</EM> has a keyword option that allowsyou to reset the terminal by outputting the initializationstrings (there are several) from a <EMCLASS="emphasis">terminfo</EM>description:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>tput init</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">The command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>tput reset</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">issues the reset strings fromthe <EMCLASS="emphasis">terminfo</EM> entry.If no reset strings are defined,the initialization strings are issued instead, and thecommand acts exactly like <EMCLASS="emphasis">tput init</EM>.</P><PCLASS="para">In earlier releases of System V, these keywords are notsupported, and you must issue multiple <EMCLASS="emphasis">tput</EM> commandsto output each of the initialization or reset strings by name.</P><PCLASS="para">The following shell program, contributed by Tony Hansen ofAT&amp;T, will do the trick:</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist">&#13;<ACLASS="co"HREF="ch25_10.htm"TITLE="25.10 Squash Extra Blank Lines ">-s</A> &#13;</PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">&#13;#!/bin/sh# Evaluate and output the iprog capabilityeval `tput iprog`# output the is1 and is2 initialization stringstput is1tput is2# if the terminal supports tabs, set them# otherwise, disable themif [ -n &quot;`tput ht`&quot; ]then stty tabs; tabs -8else stty -tabsfi# output contents of the initialization file, if presentcat -s &quot;`tput if`&quot;# output the is3 initialization stringtput is3</PRE></TD></TR></TABLE></P><PCLASS="para">&#13;See your system manuals, or O'Reilly &amp; Associates' <EMCLASS="emphasis">termcap &amp; terminfo</EM>,for a description of the various initialization capabilities used in thisscript.<ACLASS="indexterm"NAME="AUTOID-5697"></A><ACLASS="indexterm"NAME="AUTOID-5698"></A></P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN> <SPANCLASS="bibliomisc">from O'Reilly &amp; Associates' <CITECLASS="citetitle">termcap &amp; terminfo</CITE>, Chapter 4</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="ch05_11.htm"TITLE="5.11 Initializing the Terminal with tset "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.11 Initializing the Terminal with tset "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="CHAPTER"HREF="ch06_01.htm"TITLE="6. Shell and Environment Variables"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 6. Shell and Environment Variables"BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">5.11 Initializing the Terminal with tset </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">6. Shell and Environment Variables</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 &amp; 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 + -