Created
April 4, 2019 11:58
-
-
Save chr5tphr/e525a72e7907b95882dda4173574adda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
usg = [] | |
loop { | |
begin | |
usg = ([IO.popen(["df", "--output=used", "--block-size=1024", "."]).readlines[1].to_i] + usg)[0, 5] | |
if usg.length > 4 | |
STDOUT << "\r" << (->(x){x.sum / x.length}).call(usg[0..-2].zip(usg[1..-1]).collect {|x, y| x - y}) << " KiB/s " | |
end | |
sleep 0.5 | |
rescue Interrupt | |
break | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment