9

Is there a terminal emulator (like GNOME terminal) for linux/unix out there, which allows for highlighting a single word always (such as "highlight the word FAIL in red")? Or maybe is there a plugin for the GNOME terminal (if such a thing like "plugins for the gnome-terminal" exists).

The solution should highlight the word regardless of what application is being run inside the terminal, i.e. running cat test.txt should highlight the word as well as make all.

Any help is greatly appreciated by my bleary-eyed eyes.

scravy
  • 193
  • 1
  • 6
  • 1
    KDE Konsole will highlight any word that is in its search bar - you can run this under Gnome. Would that work? – Paul Jan 16 '12 at 23:54
  • [Linux terminal: Keyword highlighting similar to MobaXTerm without piping](https://unix.stackexchange.com/q/492621/44425), [Is there a terminal emulator for linux that can highlight keywords for all the printed output](https://softwarerecs.stackexchange.com/q/71706/3579), – phuclv Apr 16 '20 at 14:02

3 Answers3

12

Using bash, you can highlight all the word 'FAIL' in red using the following commands:

txtred=$(echo -e '\e[0;31m')
txtrst=$(echo -e '\e[0m')
bash | sed -e "s/FAIL/${txtred}FAIL${txtrst}/g"

What it does is creating a new bash shell and editing stdout of this new shell using sed. If you want to end the stdout edition, simply type exit to return back to your previous shell. You can find more color commands here. The echo -e variation is needed to get the real ESCAPE value of \e.

I tried it with echo and cat in this subshell and it is working. However, it breaks programs expecting a terminal as their output like vi. I guess that it would also break programs using special output buffering. It is also breaking commands like echo -n FAIL and change the behavior of commands like ls (ls prints many files per line when the output is a terminal, and one file per line when the output is a pipe).

jfg956
  • 1,159
  • 8
  • 8
2

clide works fine. I use it on RHEL 6.2, from the EPEL repository

golimar
  • 1,522
  • 1
  • 17
  • 35
-3

You can use

cat filename|grep word -w 

where filename is the name of the file and word is the word you are looking to highlight.

Excellll
  • 12,627
  • 11
  • 51
  • 78