Created
July 20, 2020 05:59
-
-
Save kaihendry/bc8835eddafdb8f92df0b4f019184e65 to your computer and use it in GitHub Desktop.
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 | |
cache=~/.cache/sloc2 | |
count() { | |
echo Arg "$@" >&2 | |
if ! test -d "$1" | |
then | |
echo $1 not a dir >&2 | |
return | |
fi | |
cd $1 | |
fullpath=$(readlink -f .) | |
count=${cache}${fullpath}/count | |
if ! test -f "$count" | |
then | |
cachedir=${cache}${fullpath} | |
mkdir -v -p "$cachedir" | |
for srcdir in * | |
do | |
echo -n "$srcdir " >&2 | |
echo $srcdir$(test -d $srcdir && echo "/") $(find "$srcdir" -type f -exec cat {} + | wc -l) | |
done | sort -k2 -n -r > "$count" | |
else | |
echo Using pre-existing cache "$count" >&2 | |
fi | |
nextdir=$(umenu < "$count") | |
count $nextdir | |
} | |
count "${1:-.}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment