@canadaduane@lemmy.ca avatar

canadaduane

@canadaduane@lemmy.ca

This profile is from a federated server and may be incomplete. Browse more on the original instance.

Is there such a thing as split-screen grep?

I want to run a command and see all of its output on the left hand side, while simultaneously searching/grepping for particular lines on the right hand side. In other words, I want a temporary vertically split screen in my CLI, ideally with scrollback on each side of the split, but where I expect the left hand side to be...

canadaduane,
@canadaduane@lemmy.ca avatar

ChatGPT suggests the following:

  1. Run tmux
  2. rsync -naP --exclude-from=rsync-homedir-local.txt /home/$USER/ $BACKUPDIR/ | tee /tmp/rsync_output.txt
  3. Ctrl+B % # splits screen vertically
  4. Ctrl+B right-arrow-key # moves to right split
  5. tail -f /tmp/rsync_output.txt | grep denied

Not quite a one-liner, but I can see how tmux is a big help here.

canadaduane,
@canadaduane@lemmy.ca avatar

Elegant and flexible, thank you!

canadaduane,
@canadaduane@lemmy.ca avatar

Thanks! I’m curious if there is a way to do this as a one-liner?

canadaduane,
@canadaduane@lemmy.ca avatar

Given encouragement to try tmux, here is what I’ve come up with as a “one-liner” (script) that does what I was originally looking for:


<span style="color:#323232;">#!/bin/sh
</span><span style="color:#323232;">
</span><span style="color:#323232;">tmux new-session -d -s split_screen_grep ; 
</span><span style="color:#323232;">  send-keys "/bin/sh -c '$1' | tee /tmp/split_screen_grep.txt" C-m ; 
</span><span style="color:#323232;">  split-window -h ; 
</span><span style="color:#323232;">  select-pane -t 1 ; 
</span><span style="color:#323232;">  send-keys "tail -f /tmp/split_screen_grep.txt | grep '$2'" C-m ;
</span><span style="color:#323232;">
</span><span style="color:#323232;">tmux attach-session -t split_screen_grep
</span>

I use it as follows, first arg is a command, second arg is a pattern to search for:


<span style="color:#323232;">$ ./split-grep "cat big_file.txt" "tmux"
</span>
canadaduane,
@canadaduane@lemmy.ca avatar

Thanks!

canadaduane,
@canadaduane@lemmy.ca avatar

This is the case for me as well. I tried NixOS this weekend, and even though it has more adoption than Guix, it still does not have 100% coverage of all software I wanted. That said, the packages I did install were pretty up-to-date. I guess NixOS is as close to “critical mass” as we’ve got when it comes to this type of OS. But if I were a wizard devops type person with more time, I’d probably enjoy Guix more.

canadaduane,
@canadaduane@lemmy.ca avatar

Keep an eye on Pop COSMIC. It isn’t ready yet, but I’d give it 4 months and I think it would be a great match for something like rpi.

canadaduane,
@canadaduane@lemmy.ca avatar

Is it possible to get this to work with OBS studio? I see the author mentions OBS as an “Alternative Project” but it seems ideal to have these pieces work together.

canadaduane,
@canadaduane@lemmy.ca avatar

This is really cool in concept, but it is SO SLOW. OMG.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #