Skip to main content
Slow internetz killed my edits
Source Link
jasonwryan
  • 74.9k
  • 35
  • 204
  • 230

The readline commands that you are looking for are the history-search-* commands:

history-search-forward
Search forward through the history for the string of characters between the start of the current line and the current cursor position (the point). This is a non-incremental search. 

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.

Binding these in your .inputrc, like so:

"\e[A": history-search-backward # arrow up "\e[B": history-search-forward # arrow down will allow you to enter the first letters of a command, and then use the Up and Down/kbd> keys to traverse the history for only those commands that begin with that string of characters. For example, entering: `vi` and then Up would jump to the first previous command beginning with `vi`, like `vim somefile`, while again entering Up would take you to the `vim` command before that in your `.bash_history`. Similarly, Down would move you forward through those same instances. You can read through the full list of readline keybindings here:
"\e[A": history-search-backward            # arrow up
"\e[B": history-search-forward             # arrow down
http://linux.about.com/library/cmd/blcmdl3_readline.htm

will allow you to enter the first characters of a command, and then use the Up and Down keys to move through only those commands in your .bash_history that begin with that string.

For example, entering vi and the Up would take you to the first previous command beginning with vi, like vim somefile. Entering Up would take you to the next previous instance, and so on.

You can read more about all of the readline bindings here: http://linux.about.com/library/cmd/blcmdl3_readline.htm

The readline commands that you are looking for are the history-search-* commands:

history-search-forward
Search forward through the history for the string of characters between the start of the current line and the current cursor position (the point). This is a non-incremental search.

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.

Binding these in your .inputrc, like so:

"\e[A": history-search-backward # arrow up "\e[B": history-search-forward # arrow down will allow you to enter the first letters of a command, and then use the Up and Down/kbd> keys to traverse the history for only those commands that begin with that string of characters. For example, entering: `vi` and then Up would jump to the first previous command beginning with `vi`, like `vim somefile`, while again entering Up would take you to the `vim` command before that in your `.bash_history`. Similarly, Down would move you forward through those same instances. You can read through the full list of readline keybindings here: http://linux.about.com/library/cmd/blcmdl3_readline.htm

The readline commands that you are looking for are the history-search-* commands:

history-search-forward
Search forward through the history for the string of characters between the start of the current line and the current cursor position (the point). This is a non-incremental search. 

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.

Binding these in your .inputrc, like so:

"\e[A": history-search-backward            # arrow up
"\e[B": history-search-forward             # arrow down

will allow you to enter the first characters of a command, and then use the Up and Down keys to move through only those commands in your .bash_history that begin with that string.

For example, entering vi and the Up would take you to the first previous command beginning with vi, like vim somefile. Entering Up would take you to the next previous instance, and so on.

You can read more about all of the readline bindings here: http://linux.about.com/library/cmd/blcmdl3_readline.htm

Source Link
jasonwryan
  • 74.9k
  • 35
  • 204
  • 230

The readline commands that you are looking for are the history-search-* commands:

history-search-forward
Search forward through the history for the string of characters between the start of the current line and the current cursor position (the point). This is a non-incremental search.

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.

Binding these in your .inputrc, like so:

"\e[A": history-search-backward # arrow up "\e[B": history-search-forward # arrow down will allow you to enter the first letters of a command, and then use the Up and Down/kbd> keys to traverse the history for only those commands that begin with that string of characters. For example, entering: `vi` and then Up would jump to the first previous command beginning with `vi`, like `vim somefile`, while again entering Up would take you to the `vim` command before that in your `.bash_history`. Similarly, Down would move you forward through those same instances. You can read through the full list of readline keybindings here: http://linux.about.com/library/cmd/blcmdl3_readline.htm