Created
July 2, 2012 05:06
-
-
Save thenoviceoof/3031206 to your computer and use it in GitHub Desktop.
du, but with a graphical bar
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
import os | |
import sys | |
path = sys.argv[1] | |
# http://stackoverflow.com/a/943921/184159 | |
rows, columns = [int(i) for i in os.popen('stty size', 'r').read().split()] | |
dir = os.listdir(path) | |
sizes = [os.stat(d).st_size for d in dir] | |
big = max(sizes) | |
for i in range(len(dir)): | |
print dir[i], sizes[i] | |
size = int(columns*float(sizes[i])/big) | |
#from math import log as lg | |
#if sizes[i]: | |
# size = int(columns*(lg(sizes[i])/lg(big))) | |
#else: | |
# size = 0 | |
if size: | |
print "#" * size | |
else: | |
print "." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment