canadaduane, 1 year ago 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>
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>