Skip to content

Instantly share code, notes, and snippets.

@chr5tphr
Created April 4, 2019 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chr5tphr/e525a72e7907b95882dda4173574adda to your computer and use it in GitHub Desktop.
Save chr5tphr/e525a72e7907b95882dda4173574adda to your computer and use it in GitHub Desktop.
#!/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