Re: Linux Journal tip

Top Page
Attachments:
Message as email
+ (text/plain)
+ (application/pgp-signature)
+ (text/plain)
Delete this message
Reply to this message
Author: Gerard J Snitselaar
Date:  
To: Main PLUG discussion list
Subject: Re: Linux Journal tip
On 0, Darrin Chandler <> wrote:
> On Mon, Sep 18, 2006 at 10:19:57PM -0500, Mike Schwartz wrote:
> > This may be OT here, but...
> > in some contexts, Ctrl-S (along with Ctrl-Q)
> > is used for software flow control.
> > I think one of them is X-OFF and the other is X-ON.
> > I think some terminals or other devices which
> > accept and/or forward data to or from the user,
> > even generate X-OFF "automatically" when
> > appropriate, e.g., due to line congestion or
> > something like that...
> > (and then I guess X-ON later when appropriate)
>
> No, I think it's very on-topic. I've had this happen to me many, many
> times!
>
> However, I've been a fan of Ctrl-R for years. FYI, It's not really just
> a bash thing. Also works in Korn, etc. I think it's more to do with what
> you're using for your (forget the proper term) line editor (Emacs, vi,
> etc).


I don't know if the history searching is tied to emacs mode or not.
You can put the bash shell in emacs mode (default) or vi mode using
'set -o' . That allows you to edit the command line using normal emacs/vi
commands. Apparently in bash you can also say 'set editing-mode'.

All of the following stuff can be found in the history related nodes
of the bash info pages.

History is turned on by default, but it can also be turned on with:

set -o history

To list the your command history you can use the history builtin command.
Then to execute one of the commands use one of these formats:

!!  - refer to the previous command (same as !-1)
!N  - refer to the nth command in history
!-N - refer to the command N commands back in history.
!STRING - refer to the most recent command starting with STRING.
!?STRING[?] - refer to the most recent command containing STRING.
      The trailiing ? can be omitted if the STRING is followed by a newline.
^STRING1^STRING2^ - Quick substitution. Repeat the last command replacing
      STRING1 with STRING2. equivalent to '!!:s/STRING1/STRING2/'. 


The history searching commands seem to work regardless of the line-editing
mode you are in. Here are some of the commands:

`previous-history (C-p)'
     Move `back' through the history list, fetching the previous
     command.


`next-history (C-n)'
     Move `forward' through the history list, fetching the next command.


`beginning-of-history (M-<)'
     Move to the first line in the history.


`end-of-history (M->)'
     Move to the end of the input history, i.e., the line currently
     being entered.


`reverse-search-history (C-r)'
     Search backward starting at the current line and moving `up'
     through the history as necessary.  This is an incremental search.


`forward-search-history (C-s)'
     Search forward starting at the current line and moving `down'
     through the the history as necessary.  This is an incremental
     search.


`non-incremental-reverse-search-history (M-p)'
     Search backward starting at the current line and moving `up'
     through the history as necessary using a non-incremental search
     for a string supplied by the user.


`non-incremental-forward-search-history (M-n)'
     Search forward starting at the current line and moving `down'
     through the the history as necessary using a non-incremental search
     for a string supplied by the user.


`history-search-forward ()'
     Search forward through the history for the string of characters
     between the start of the current line and the point.  This is a
     non-incremental search.  By default, this command is unbound.


`history-search-backward ()'
     Search backward through the history for the string of characters
     between the start of the current line and the point.  This is a
     non-incremental search.  By default, this command is unbound.


`yank-nth-arg (M-C-y)'
     Insert the first argument to the previous command (usually the
     second word on the previous line) at point.  With an argument N,
     insert the Nth word from the previous command (the words in the
     previous command begin with word 0).  A negative argument inserts
     the Nth word from the end of the previous command.


`yank-last-arg (M-. or M-_)'
     Insert last argument to the previous command (the last word of the
     previous history entry).  With an argument, behave exactly like
     `yank-nth-arg'.  Successive calls to `yank-last-arg' move back
     through the history list, inserting the last argument of each line
     in turn.


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss