This is possible. You want to investigate Ctrl-R and a little bit of history expansion.
From man bash
:
reverse-search-history (C-r)
Search backward starting at the current line and moving 'up'
through the history as necessary. This is an incremental
search.
History expansions introduce words from the history list into the input
stream, making it easy to repeat commands, insert the arguments to a
previous command into the current input line, or fix errors in previous
commands quickly.
Further explanations on reverse-search-history:
Hit Ctrl-R and start typing in a string. You will see the last line from your history that contains the string in any position, updated for every keypress. Hit Ctrl-R more times to see preceding lines without typing in new characters. Hit enter to accept and launch the command, left-right to edit the command, up-down to browse history without limiting to the searched string starting from the line you found, Ctrl-C to abandon the search.
Ctrl+R
, typessh
.