[wellylug] Take a hint

Grant McLean grant at mclean.net.nz
Wed Sep 8 09:17:24 NZST 2004


On Tue, 2004-09-07 at 21:42, jumbophut wrote:
> On Tue, 07 Sep 2004 10:12:09 +1200, Chris Hodgetts wrote:
> > I also find that Ctrl-R in the command line also very  helpful
> > 
> Yes, very.  I'm learning a lot today!
> 
> One question though -- apparently Ctrl-S is supposed to let you scroll
> back through the history (if you press Ctrl-R one too many times, for
> example), but on my machine, bash hangs when I do that.  Do you have
> this problem too?

If you type the command 'stty -a', the output will include this:

  start = ^Q; stop = ^S;

This indicates that pressing Ctrl-S will stop output to your terminal 
and pressing Ctrl-Q will start it again.  One example of when this is 
useful is if you're running a make command and you notice some 
suspicious looking message flash by.  Pressing Ctrl-S will pause the 
output enabling you scroll back and examine the messages, then if 
you're happy, you'd press Ctrl-Q to un-pause the output.  (Under 
MS-DOS, the 'Scroll Lock' key performs a similar function).

The significance of this is that it happens in the TTY driver inside
the kernel.  The driver intercepts the Stop and Start characters and
the program you're running never sees them.

One workaround would be to tell the TTY driver to use something other
than Ctrl-S for Stop.  For example, you could map it to Ctrl-F:

  stty stop ^F

(Note to enter ^F in Bash, you would type Ctrl-V Ctrl-F)

Another option would be to re-map what key Bash recognises for the
forward-search-history function.  In this case, Ctrl-F is probably
a better choice from a mnemonic perspective.

The command line editing in Bash is implemented using the GNU 
readline library.  Readline has some default mappings plus a global
config file in /etc/inputrc and a per-user ~/.inputrc

To map Ctrl-F to search forwards through history, create a file
called .inputrc in your home directory and put this line in it:

  "\C-F": forward-search-history

You may also want to add these two lines as well:

  "\e[5D": backward-word
  "\e[5C": forward-word

These allow the use of the Ctrl-Left-Arrow and Ctrl-Right-Arrow to
move left and right a word at a time.

Regards
Grant





More information about the wellylug mailing list