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

📄 ch42_04.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
></BLOCKQUOTE></P><PCLASS="para">Call it something like <EMCLASS="emphasis">sane</EM>.You may need to execute it by typingLINEFEEDorCTRL-jbefore andafter.</P><PCLASS="para">If that doesn't work perfectly, here's what to do.The next time you log in and your screen works just right,typing <EMCLASS="emphasis">stty&nbsp;everything</EM> or <EMCLASS="emphasis">stty -g</EM> (see below) shouldhelp you decide exactly what parameters to use in your <EMCLASS="emphasis">sane</EM>command.</P></LI><LICLASS="listitem"><PCLASS="para">If the system seems to treat every character youtype as a separate command (and you may not be able to see thecharacters you type):</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>reset</B></CODE>r: Command not found.: No previous regular expression: No current filename: No lines in the buffer<CODECLASS="userinput"><B>q</B></CODE>%</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46882"></A>(It actually doesn't look quite like that, but the first <CODECLASS="userinput"><B>e</B></CODE> startedthe editor named <EMCLASS="emphasis">e</EM>.The <CODECLASS="userinput"><B>s</B></CODE>, <CODECLASS="userinput"><B>e</B></CODE>, and <CODECLASS="userinput"><B>t</B></CODE> are all read as commands by<EMCLASS="emphasis">e</EM>.You have to quit <EMCLASS="emphasis">e</EM> by typing its <CODECLASS="literal">q</CODE> command.Sheesh!)</P><PCLASS="para">You should make a shell function or alias&nbsp;- or, put a<SPANCLASS="link">symbolic link (<ACLASS="linkend"HREF="ch18_04.htm"TITLE="More About Links ">18.4</A>)</SPAN>orshell script in your<SPANCLASS="link"><EMCLASS="emphasis">bin</EM> directory (<ACLASS="linkend"HREF="ch04_02.htm"TITLE="A bin Directory for Your Programs and Scripts ">4.2</A>)</SPAN>-thatlets you run the command fromthe previous step (<EMCLASS="emphasis">reset</EM>, <EMCLASS="emphasis">stty&nbsp;sane</EM>, etc.) by typing a singlecharacter.I picked <CODECLASS="literal">]</CODE> (right square bracket) as the name of mine.To make mine, I made a symlink in my <EMCLASS="emphasis">bin</EM>:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>ln -s /usr/ucb/reset ]</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">(Your system's <EMCLASS="emphasis">reset</EM> command may have a different pathname.)Now, to fix a goofed-up terminal, I just type a <CODECLASS="literal">]</CODE> at a shell prompt(it may need aLINEFEEDorCTRL-jbefore and after).</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46909"></A><ACLASS="indexterm"NAME="AUTOID-46912"></A>Best of all, if your system has the command <EMCLASS="emphasis">stty -g</EM>, you can use it tosave your favorite terminal settings in a file.Then, when your terminal is goofed up, read those settings in again fromthe file.Here's how.First, when your terminal is working just the way you want it, type:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>stty -g &gt;$HOME/.stty</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">Then make your alias, shell script, or shell function named <EMCLASS="emphasis">sane</EM>,<CODECLASS="replaceable"><I>]</I></CODE>, etc. (previously explained) that runs the command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>stty `cat $HOME/.stty`</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">This should restore your terminal the way it was when you firstran the <EMCLASS="emphasis">stty -g</EM> command.</P><PCLASS="para">If your system doesn't have <EMCLASS="emphasis">stty -g</EM>, you can fake it.Run the command <EMCLASS="emphasis">stty&nbsp;everything</EM>or <EMCLASS="emphasis">stty -a</EM> and look at the settings:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>stty everything</B></CODE>speed 38400 baud, 0 rows, 0 columnsparenb -parodd cs7 -cstopb -hupcl cread -clocal -crtscts-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclcixon -ixany -ixoff imaxbelisig iexten icanon -xcase echo echoe echok -echonl -noflsh -tostopechoctl -echoprt echokeopost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tabserase  kill  werase rprnt  flush  lnext   susp   intr   quit  stop   eof^?     ^U     ^W     ^R     ^O     ^V     ^Z/^Y  ^C     ^\   ^S/^Q  ^D</PRE></BLOCKQUOTE></P><PCLASS="para">Then check your <EMCLASS="emphasis">stty</EM> manual page and read about those settings(some of them, like the parity settings, might not be appropriate for allyour login sessions).Put the settings in your <EMCLASS="emphasis">sane</EM> or <CODECLASS="replaceable"><I>]</I></CODE> command:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">stty icanon echo erase '^?' kill '^u' ...</PRE></BLOCKQUOTE></P><PCLASS="para">Note that if you use several different terminals, each may have differentsettings.Make yourself several <EMCLASS="emphasis">sane</EM> commands; you might<SPANCLASS="link">select one automatically as you log in (<ACLASS="linkend"HREF="ch02_12.htm"TITLE="Automatic Setups for Different Terminals ">2.12</A>)</SPAN>.</P></LI></UL><PCLASS="para">If worse comes to worst, try the steps from article<ACLASS="xref"HREF="ch42_02.htm"TITLE="Fixing a Hung Terminal or Job ">42.2</A>.Find another place to log in to your account.Run <EMCLASS="emphasis">ps</EM> to find your processes on the hung-up terminal or windowand kill them.Then turn off the terminal or close the window and log in again.(If you didn't have a way to kill the processes before you logged inagain, be sure to kill your old processes right away after you log in.)</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</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="ch42_03.htm"TITLE="42.3 Why Changing TERM Sometimes Doesn't Work "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 42.3 Why Changing TERM Sometimes Doesn't Work "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="ch42_05.htm"TITLE="42.5 Checklist: Screen Size Messed Up? "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 42.5 Checklist: Screen Size Messed Up? "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">42.3 Why Changing TERM Sometimes Doesn't Work </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">42.5 Checklist: Screen Size Messed Up? </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 + -