annacrombie / plot

plot on the command line
MIT License
113 stars 9 forks source link

Following stdin not drawing graph #27

Closed xrat closed 1 year ago

xrat commented 1 year ago

First of all, I am very glad I found this wonderful tool.

I fail to make plot draw graphs as values come in at stdin while it does work if I use files. For instance, in Bash for i in {0..9}; do echo $i ; sleep .5; done| plot will show the graph only after 5s. If I write the sequence of numbers to a file in the background plot -f -i file works as expected. plot starts showing and updating the graph as the first number is written to the file. Did I miss something in the docs?

plot 0.5.1, Kernel 5.10.0, Bash 5.1.4

annacrombie commented 1 year ago

First of all, you still need to use -f when you are reading from stdin. The other problem with getting data from stdin is that pipes are buffered by default. In order to get around pipe buffering you can try to add the nonblocking flag to stdin:

for i in {0..9}; do echo $i ; sleep .5; done | plot -f -i -:n

To read more about the input flags see the -i section in the man page.

xrat commented 1 year ago

I had tried -f and stdbuf but to no avail. It works with -i -:n, though. Thank you!