From 0058e33cdb1a169dabc0b790790a69015897d2e0 Mon Sep 17 00:00:00 2001 From: Morgan Wattiez Date: Tue, 22 Oct 2019 07:57:44 +0200 Subject: [PATCH] helper for getting lines of code stats --- dot_zsh_functions | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/dot_zsh_functions b/dot_zsh_functions index 0116f50..df17455 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -116,17 +116,30 @@ function skip { cut -d' ' -f$n- } -# Unique lines of code -# Via https://text.causal.agency/004-uloc.txt -function uloc { - find . -type f \( \ +cmd_loc="find . -type f \( \ -name '*.py' \ -o -name '*.rb' \ -o -name '*.go' \ -o -name '*.java' \ -o -name '*.c' -o -name '*.h' \ -o -name '*.js' \ - \) -exec \cat \{\} \; | sed -e 's/^[ \t]*//;s/[ \t]*$//' | sort -u | wc -l + -o -name '*.tsx' \ + -o -name '*.md' \ + -o -name '*.xml' \ + -o -name '*.groovy' \ + -o -name '*.gradle' \ + -o -name '*.properties' \ + \) -exec \cat \{\} \; | LANG=C LC_CTYPE=C sed -e 's/^[ \t]*//;s/[ \t]*$//'" + +# Unique lines of code +# Via https://text.causal.agency/004-uloc.txt +function uloc { + eval "$cmd_loc | LANG=C LC_CTYPE=C sort -u | wc -l" +} + +# Top lines of code +function toploc { + eval "$cmd_loc | cut -c 1-100 | LANG=C LC_CTYPE=C sort | uniq -c | sort -nr" } # Find files bigger than X size and sort them by size