clojure progressbar bash


/ Published in: Clojure
Save to your folder(s)

first try, use with care


Copy this code and paste it in your HTML
  1. (defn progress
  2. "prints a progressbar to shell, use repeatetly to 'update' the progressbar"
  3. [posV maxV & text]
  4. (let [ barmax 80
  5. multiplier (/ barmax maxV)
  6. pos_ (min (round (* posV multiplier)) barmax)
  7. start \[
  8. end \]
  9. left (apply str (repeat pos_ \=))
  10. right (apply str (repeat (- barmax pos_) \-))
  11. style \>
  12. msg (first text)]
  13. (binding [*out* *err*]
  14. (print (str "\r" start left style right end) msg) (flush))
  15.  
  16. )
  17. )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.