1

I'm doing my thesis with Node-red on Raspberry Pi. The Raspberry Pi will run only node-red, so I thought of spicing things up a bit for the Raspberry Pi terminal.

I'm already piping the Node-red output through lolcat, but I still feel like it could use something more... Something like a cow saying all those logs.

So the problem is that cowsay outputs only on the program exit. If I read one line in bash script and push it to cowsay, like in another question here, there's a new cow for every logging message. This would clutter the terminal with a horde of cows, which I like the sound of, but isn't really practical.

I feel like I'm pushing the limits of this being easier to do from scratch instead of using cowsay, but I'll ask anyway: How do I have a single cow from cowsay saying the log messages, having the logs scroll upwards in the speech bubble without the cow moving?

PuuKala
  • 13
  • 3
  • You could try calling cowsay with enough blank lines in front of it so the cow always appears in the same spot. – WinEunuuchs2Unix Jul 02 '19 at 19:26
  • True, thought of something like that. I'm just not sure how to save the screenful of log lines to be pushed to cowsay... – PuuKala Jul 03 '19 at 09:31

1 Answers1

0

The whole idea of a terminal is to print output line by line. So having a fixed bottom part and a change in previous lines goes against this.

However you could simulate this with a terminal multiplexer (e.g. tmux or screen). They create split screen terminals. This way you can have e.g. the bottom 10% of the screen be one terminal where the cow is printed and left untouched. In the top 90% the actual action is happening and the lines scroll as expected.

Take a look at terminal multiplexers here.

FelixJN
  • 2,288
  • 11
  • 17
  • Ah yes, terminal multiplexer. This certainly works. Any way to start this all up in a script? I've got the lolcat only version in post-boot script. Image of the test: https://imgur.com/a/9YfYEgO – PuuKala Jul 03 '19 at 07:13
  • 1
    Googled a bit and found the answer to my comment. Now my .bashrc has lines: `tmux new-session -d ' | '; tmux split-window -v -l 6 ' - | ; '; tmux -2 attach-session -d`. I don't think it's the cleanest lines of commands as I just copied some tmux commands without understanding everything, but it works. – PuuKala Jul 03 '19 at 16:59
  • @PuuKala : `tmux` allows for creating a config file that can be loaded with `-f `. This way your bashrc would be less crowded. – FelixJN Jul 04 '19 at 08:55