I need to simulate selecting (highlighting) text that is in the terminal buffer. It's long past stdout so all the grep/awk/sed/redirection stuff is not relevant AFAIK. Plus I don't want it highlighted during formatting of stdout. I need it to go to stdout unhighlighted, then highlight it. Simulating selection.
Here is the scenario...
A Bash script calls "ls -1" and outputs the following to stdout and then the terminal buffer?
$ ls -1 a.txt b.txt c.txt
Now I need a command I can put in a Bash script that will find and highlight "b.txt".
$ termsearch b.txt a.txt [b.txt] c.txt
Where "termsearch" is a made up command I think I need and it converts b.txt to black text with white background (highlighted) and the rest of the text is white on black background. I think the problem is that you can't really edit the buffer and change text style like this.
I can use screen interactively to find "b.txt", but it doesn't highlight (the main goal) and I don't know if it's possible to script screen commands anyway. So I've given up on screen. The script command just dumps stdout to a file, but I don't want to search a file. I need to search the terminal buffer and highlight the results on screen without more stdout. What I want is already out, it just needs to be highlighted.
I'm thinking ncurses is the way to go, but I have never coded with it and it looks complicated. So before I dive in, I'm asking if anyone can think of another way to do this and validate that ncurses can even do what I want.
screen. That's your best bet. Or its more modern (but less ubiquitous) replacement,