Created
October 15, 2012 18:55
-
-
Save pjkix/3894365 to your computer and use it in GitHub Desktop.
shell script for generating stats about less files
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
#!/bin/bash | |
## v1.0.8b(less) | |
## this script will generate LESS stats | |
## NOTE: you need to run --type-set=less=.less or add this to .ackrc | |
## TODO: ack ignroes contrib by default, need to add this to find as well | |
### example output | |
# LESS STATS | |
# ---------- | |
# Floats: 132 | |
# Headings: 107 | |
# Margins: 432 | |
# Paddings: 463 | |
# Font-Sizes: 170 | |
# Importants: 56 | |
echo 'LESS STATS' | |
echo '=========' | |
echo | |
echo 'General: ' | |
echo '----------' | |
## number of files | |
echo -n "Number of LESS files: " | |
ack --less -f | wc -l | |
## number of lines | |
# ack --nogroup --less --passthru * | wc -l | xargs echo "Number of Lines of Code (LoC)" | |
## longest file | |
echo 'File Length (LoC):' | |
find . -iname "*.less" | grep -v contrib | xargs wc -l | sort -r | |
# find . \( -name contrib \) -prune -o -iname "*.less" | xargs wc -l | sort -r | |
echo | |
echo 'File Size (KBytes)' | |
# find . -iname "*.less" | xargs ls -l | awk '{print $5 "\t" $9}' | sort -nr ## Bytes | |
# find . -iname "*.less" | xargs ls -l | awk '{printf("%.1fK\t", $5 / 1024); print "\t" $9}' | sort -nr ## KB | |
find . \( -name contrib \) -prune -o -iname "*.less" -print0 | xargs -0 du -hsc | sort -nr ## block size, this sucks but easy to sort | |
# find . -iname "*.less" -print0 | du -hsc ## block size | |
# stat -f "%z Bytes" stats.sh ## actual file size in bytes | |
echo | |
echo 'ISSUES' | |
echo '----------' | |
# code comments for FIXME: and TODO: tags | |
echo "FIXME: " | |
ack --nogroup --less FIXME | |
echo | |
echo "TODO: " | |
ack --nogroup --less TODO | |
echo | |
echo 'Props: ' | |
echo '----------' | |
## append search results | |
# echo -n "test:" | |
echo -n "Floats: " | |
ack --nogroup --less float | wc -l | |
echo -n "Headings: " | |
ack --nogroup --less h[1-6] | wc -l | |
echo -n "Margins: " | |
ack --nogroup --less margin | wc -l | |
echo -n "Margins 0: " | |
ack --nogroup --less --match="margin-?(top|right|bottom|left)?\s*:\s*0" | wc -l | |
echo -n "Paddings: " | |
ack --nogroup --less padding | wc -l | |
echo -n "Padding 0: " | |
ack --nogroup --less --match="padding-?(top|right|bottom|left)?\s*:\s*0" | wc -l | |
echo -n "Importants: " | |
ack --nogroup --less important | wc -l | |
## generated content | |
echo -n "Content: " | |
ack --nogroup --less --match="content ?+:" | wc -l | |
echo | |
## Fonts | |
echo "Font-Sizes: " | |
echo '----------' | |
echo -n "Total" | |
ack --nogroup --less font-size | wc -l | |
echo "Uniqe " | |
ack --nogroup --less --match="font-size ?+: ?+.+;" -o -h | sort | uniq -i -c | sort -r | |
echo | |
## colors | |
echo 'Colors:' | |
echo '----------' | |
echo -n "Hex: " | |
ack --nogroup --less --match="#[0-9a-fA-F]{3,6}" -o -h | wc -l | |
echo -n "RGB(a): " | |
ack --nogroup --less --match="rgba?\w*\(.*\)" -o -h | wc -l | |
echo | |
### unique | |
echo 'Unique Colors:' | |
echo '----------' | |
echo -n 'Hex: ' | |
ack --nogroup --less --match="#[0-9a-fA-F]{3,6}" -o -h | sort | uniq -i -c | wc -l | |
echo | |
ack --nogroup --less --match="#[0-9a-fA-F]{3,6}" -o -h | sort | uniq -i -c | sort -r | |
echo | |
echo -n 'RGB(a): ' | |
ack --nogroup --less --match="rgba?\w*\(.*\)" -o -h | sort | uniq -i -c | wc -l | |
echo | |
ack --nogroup --less --match="rgba?\w*\(.*\)" -o -h | sort | uniq -i -c | sort -r | |
echo | |
## Images | |
echo "Images:" | |
echo '----------' | |
echo -n "URLs:" | |
ack --nogroup --less --match="url\w?\(.*\)" -o -h | wc -l | |
### unique urls | |
echo -n "Unique URLs:" | |
ack --nogroup --less --match="url\w?\(.*\)" -o -h | sort | uniq -i -c | wc -l | |
echo | |
ack --nogroup --less --match="url\w?\(.*\)" -o -h | sort | uniq -i -c | sort -r | |
echo | |
## Vars | |
echo "Vars:" | |
echo '----------' | |
echo -n "Vars:" | |
ack --nogroup --less --match="@.*\w?+:\w?+.*;" -o -h | wc -l | |
### unique urls | |
echo -n "Unique Vars:" | |
ack --nogroup --less --match="(@.*\w?):\w?.*;" -o -h | sort | uniq -i -c | wc -l | |
echo | |
ack --nogroup --less --match="(@.*\w?):\w?.*;" -o -h | sort | uniq -i -c | sort -r | |
exit 0 | |
#done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment