6

I wanted to use the reverse-i-search as usual by pressing Ctrl+R to search my last ssh command. When I tried, I was only able to write "ss" but not continue with "h". Additionally when I hit Ctrl+H again, nothing happens. Does anybody have an explanation?

I am using Ubuntu 12.04 and in the pasttime this worked fine (on my other computer with the same os)

4

Try like this:

[...] first press Ctrl+R then start typing the command or any part of the command that you are looking for. You'll see an auto-complete of a past command at your prompt. If you keep typing, more specific options will appear. You can also press Ctrl+R again as many times as you want to, this goes back in your history to the previous matching command each time

Once you see a command you like, you can either run it by pressing return, or start editing it by pressing arrows or other movement keys.

Source: Navigating Bash History with Ctrl+R.

  • I tried again with other commands. Some work. So my explanation would be, that since I used the ssh command the last time, I deleted the terminal history. Question: Does the input prompt of ctrl r stop, if the character combination never occured before? meaning I could not write "h" because "ss" occured, but not "ssh"? – aldorado Oct 27 '13 at 19:01
  • @aldorado You can try "ss" if this didn't ocured in the time, you will get the right command. If sh ocurred in this time, then press again Ctrl+R and type again "ss" and so on. – Radu Rădeanu Oct 27 '13 at 19:07
4

From: https://help.ubuntu.com/community/UsingTheTerminal

An extremely handy tool :: Incremental history searching

in terminal enter:

gedit  ~/.inputrc

then copy/paste and save:

"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char

FROM now on and many agree this is the most useful terminal tool saves you a lot of writing/memorizing... all you need to do to find a previous command is to enter say the first 2 or 3 letters and upward arrow will take you there quickly. Say I want:

for f in *.mid ; do timidity "$f"; done

all I need to do is enter

fo

and hit upward arrow. Command will soon appear!

0

Run this command in terminal. Use Ctrl+S to toggle forward when searching for commands in the terminal. For current session- add it to .bashrc to disable it permanently.

stty -ixon

ctrl+r -> reverse i search

ctrl+s -> i search 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.