On 14 May 2006, at 02:48, Sarah Fortune wrote:
> kevin lyda <kevin at ie.suberic.net> quoth:
>> Getting stuff from the last command:
>>>> Full line: % !! becomes: % vi foo.c bar.c
>> Last arg : % svn ci !$ becomes: % svn ci bar.c
>> In bash you can use Alt-. to fill in the last argument, it's nicer
> than !$
> because you can see what it is before running the command.
This also has some nice additional features. Repeatedly pressing
Alt-. cycles back through the history, replacing into the command
line the last argument from each line in turn, and it's also possible
to get an argument other than the last. Also, this shortcut key is
actually Meta-. (also Meta-_) where Meta means the Meta key, when
available (the diamond on a Sun keyboard, for instance), and is
usually mapped to the Alt key on a PC style keyboard and conveniently
for remote usage (where special modifiers like Alt and Meta can often
not be used) Meta-X can be replaced by Esc X .
These convenient features are provided to bash courtesy of the GNU
readline library, which is also used in other programs and is
available to anybody who's writing a program with a command line. man
readline will provide a good introduction to its many useful features
- my most used one would be reverse-search-history, bound to Ctrl-r
by default - you'll rarely need to do history|grep again.
Because it's readline the keys used are configurable (defaulting to
emacs like, of course, but there's a vi mode for the afflicted).
Niall
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!