Trick: Change the command line editing interface in bash

From SHellium Wiki
Jump to: navigation, search
Geographylogo.png In other languages: English | Afrikaans | Albanian | Arabic | Brazilian | Bulgarian | Catalan | Chinese | Croatian | Czech | Danish | Dutch | Esperanto | Estonian | Filipino | Finnish | Flemish | French | German | Greek | Hebrew | Hindi | Hungarian | Indonesian | Italian | Japanese | Latvian | Lithuanian | Macedonian | Malay | Malayalam | Norwegian (Bokmål) | Norwegian (Nynorsk) | Persian | Polish | Portuguese | Romanian | Russian | Serbian | Slovak | Slovenian | Spanish | Swedish | Turkish | Ukrainian | Urdu

Using the bash shell if I have a cmd line like this (before pressing enter to run it):


 [bob@host ~]$ this is some long string i have typed in here 1 2 3


Right now my cursor is at 3. If I want to move it to the start (t) I'd hit ctrl+a. This is in the emacs style of editing some other commands are:

basic emacs commands
Ctrl-a Move to beginning of line.
Ctrl-e Move to end of line.
Ctrl-f Move forward one character.
Ctrl-b Move backward one character.

But say you dont like emacs say you like vi. Switch by running:

 set -o vi 

Note: use "-o emacs" to go back to the default.

Now command line editing will act more like VI. Using arrow keys will still work but now if you press ESC you can start moving and editing like VI.


Basic VI keys
w Move to next word
W Move to next blank delimited word
b Move to the beginning of the word
B Move to the beginning of blank delimited word
e Move to the end of the word
i Insert before cursor
I Insert before line
a Append after cursor
A Append after line
r Replace one character
R Replace many characters
Personal tools
Namespaces

Variants
Actions
Navigation
Indexes
SHellium Sites
Toolbox