Little Shell Trick
I've just learned a nice little trick in the OpenSolaris shell - to move one word left you can press Alt-B and to move one word right you can press Alt-F. Make sure to disable the shell top menu (using preferences), to avoid opening the File menu on Alt-F instead. Hmm I've been wondering during all my demos how to move faster inside the command line - this is it :)
Thx
Posted by muhabbet on March 15, 2009 at 10:13 PM GMT #
There are a few of these for bash(1). Ctrl+a goes to the beggining of the line, ctrl+e to the end, ctrl+d erases a character/digit, ctrl+r searches the history, ctrl+w removes a word, ...
Posted by Rafael on March 15, 2009 at 10:30 PM GMT #
It's just the same as in Emacs.
Posted by Thommy M. on March 16, 2009 at 07:22 AM GMT #
Thnks dude.
cheers,
Sourav Mohanty
Posted by Sourav Mohnaty on March 16, 2009 at 07:49 AM GMT #
Just as Thommy said, they are the Emacs keys.
So iso ALT-F or ALT-B I use META-F and META-B. On my laptop the META key is the escape-key.
One can switch between 'EMACS' mode and 'VI' mode by issuing the command:
set -o emacs (for emacs mode)
set -o vi (for vi mode)
Posted by Enno on March 16, 2009 at 01:42 PM GMT #
Within bash I do:
set -o vi
Then:
ESC+K -> Previous command line
ESC+/whatever -> Search "whatever" in the command line history
ESC+b -> Move backwards a word
ESC+w -> Move forward to the next word
And many other vi-like key bindings that don't fit within this comment box.
Posted by Antonio on March 16, 2009 at 06:45 PM GMT #
Some seems to like to make life harder than it is... ;-)
Posted by Thommy M. on March 17, 2009 at 11:32 AM GMT #
You can also map 'forward-word' and 'backward-word' in your inputrc, which saves you from having to care about which terminal app you're using. I use Ctrl+arrows, which is common in default Linux inputrc's.
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
Posted by robc on March 20, 2009 at 02:58 AM GMT #
Hopefully OpenSolaris will provide some reasonable default inputrc.
This is tracked by http://defect.opensolaris.org/bz/show_bug.cgi?id=3090.
Posted by hnhn on April 19, 2009 at 12:02 PM GMT #
Quick question though: how do I disable the shell top menu (using preferences)? It's always been a big annoyance for me in GNOME that alt+f opens the "File" menu and doesn't move forward one word in BASH like it should.
Usually you guys are so good about showing screen-shots for everything ;-)
Posted by system5 on August 05, 2009 at 04:50 AM GMT #
thanks..
Posted by cet on September 11, 2009 at 09:03 AM GMT #