Bash (and any other terminal application that uses the readline library) has search functionality. Command line edition is done by the shell, not by the terminal. (See What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?).
The main search commands are Ctrl+S and Ctrl+R, which search forward and backward respectively. These are incremental searches: after pressing Ctrl+S or Ctrl+R, type the text you want to search and you'll be brought to the next/previous occurrence of what you've typed so far.
Press any key that doesn't insert a character and that isn't Backspace to end search mode. Note that the key will have its usual effect, in particular Enter runs the command immediately. Left/Right are usually the most convenient way.
If you want to cancel the search, press Ctrl+G and you'll be returned to the command you were editing. These commands search the shell command history as well as the current command line. If you accidentally drift to a previous command line, Ctrl+G returns you to what you were typing originally.
Bash also has commands to search a single character without entering a search mode: Ctrl+] forward, Ctrl+Alt+] or Alt+- Ctrl+] backward.
Zsh has similar commands (and quite a few more). Its commands to search a single character quickly aren't bound to a convenient key by default (Ctrl+X Ctrl+F forward and none backward) unless you're in vi mode, but you can bind a key to them with bindkey
.
set editing-mode vi
in your~/.inputrc
(or just typeset -o vi
to test this) and enjoyvi
navigation in your command line: Leave input mode with Esc and use commands like42|
to move to column 42 orf;
to jump to the next semicolon and so on ... – Philippos Jul 29 '19 at 12:34vi
commands? Also, is it possible to have the terminal show, whether I'm input mode or command mode? Finally,0
works, but$
doesn't? – Shuzheng Jul 31 '19 at 07:19