Return to Snippet

Revision: 30508
at August 16, 2010 09:05 by birdspider


Initial Code
(defn progress 
	"prints a progressbar to shell, use repeatetly to 'update' the progressbar"
	[posV maxV & text]	
	(let [  barmax 80
		multiplier (/ barmax maxV)
		pos_ (min (round (* posV multiplier)) barmax)
		start \[
		end \]
		left (apply str (repeat pos_ \=))
		right (apply str (repeat (- barmax pos_) \-))
		style \> 
		msg (first text)]
		(binding [*out* *err*]
			(print (str "\r" start left style right end) msg) (flush))
		
	)
)

Initial URL

                                

Initial Description
first try, use with care

Initial Title
clojure progressbar bash

Initial Tags
Bash

Initial Language
Clojure