How to Highlight All Search Results Within the Terminal Application Screen Buffer

searchterminal

In the past I had used iTerm2 which makes search a non issue. However it has showstopper bugs with pasting from the clipboard so I must use Terminal instead. It seems the latter does not make searching a trivial task. The screenshot shows searching for event :

enter image description here

You will have noticed there is nothing highlighted. I don't know what it is actually doing.. Sometimes when searching maybe one element shows up. But that's not acceptable either: why are not all instances of the search term highlighted?

The keyboard shortcuts do not list any such shortcut: am I missing something there? https://support.apple.com/guide/terminal/keyboard-shortcuts-trmlshtcts/mac

Best Answer

  • Cmd+F to open the find window, and then type your find keyword
  • After you've entered your keyword, go to EditFindSelect All
  • Your search term should now be highlighted:

enter image description here

Unfortunately, this has no keyboard shortcut by default and you can't add a keyboard shortcut for this via the normal Mac settings (without installing a third-party automation app) because it would conflict with the "Select All" option that is being used as a top-level action inside the Edit menu, before the Find submenu.

However, you could add a keyboard shortcut for "Select All in Selection", the only downside to this is you have to select the region you want to highlight before executing the key combination. Here's how to set up this workflow:

  • Click on the  menu on the top-left and go to System Preferences
  • Select Keyboard.
  • Select the "Shortcuts" tab
  • Click on "App Shortcuts" on the lefthand side menu
  • Click on the "+" button, then select "Terminal.app" as the app, "Select All in Selection" in the Menu Title field, and the "Shortcut" key combination you want to use (Cmd+Shift+F in my case, but you can choose whatever you want).
  • Click "Add"

enter image description here

Now, inside Terminal.app you can use this like:

  • "Cmd-A" to select all
  • "Cmd-F" to open the find bar
  • Type in your search phrase
  • Because everything is still selected, you can use your shortcut you just specified (e.g. Cmd+Shift+F) to highlight your find keyword in your terminal window.