Skip to content

Instantly share code, notes, and snippets.

@davidhq
Last active March 18, 2016 22:56
Show Gist options
  • Save davidhq/9883d43146d1fb2c2c00 to your computer and use it in GitHub Desktop.
Save davidhq/9883d43146d1fb2c2c00 to your computer and use it in GitHub Desktop.
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
function loc {
if [ -z "$1" ] || [ "$1" == "all" ]; then
loc js "$2"
loc jsx "$2"
loc sh "$2"
loc sol "$2"
loc ex "$2"
loc exs "$2"
loc erl "$2"
loc go "$2"
loc rs "$2"
loc hs "$2"
loc elm "$2"
loc rb "$2"
loc py "$2"
loc html "$2"
loc css "$2"
loc json "$2"
else
local files=$(find . -name "*.${1}" -not -path "*/.git/*" -not -path "*/node_modules/*" -not -path "*/Godeps/*" -not -path "*/elm-stuff/*" -not -path "*/deps/*" -not -path "*/_build/*" -not -path "*/target/*" -not -path "*/dist/*" -not -path "*/bower_components/*" -not -path "*/tmp/*" -not -path "*/deploy/*" -not -path "*/distroot/*")
# local files=''
# source_code files "$1"
if [ -n "$files" ]; then
printf "${GREEN}${1}${NC}\n"
if [ "$2" == "total" ]; then
local total=$(wc -l $files | grep "total")
if [ -n "$total" ]; then
echo $total
else
wc -l $files
fi
else
wc -l $files
fi
echo
fi
fi
}
function loct {
loc "all" "total"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment