Skip to content

Instantly share code, notes, and snippets.

@jeremy-w
Created November 19, 2015 21:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremy-w/16fbb89cc633e96dc148 to your computer and use it in GitHub Desktop.
Save jeremy-w/16fbb89cc633e96dc148 to your computer and use it in GitHub Desktop.
fish script to list big files. Helpful in combating Massive View Controller.
function list-big-files --description 'list-big-files 250 swift dir/: list .swift files under dir having >250 lines'
set -l big_linecount 250
set -l extension swift
set -l root .
switch (count $argv)
case 0:
;
case 1:
set -l root $argv[0]
case 2:
set -l extension $argv[0]
set -l root $argv[1]
case 3:
set -l big_linecount $argv[0]
set -l extension $argv[1]
set -l root $argv[2]
default:
echo 'error: list-big-files: too many arguments: expected 0-3 args' >/dev/stderr
exit 1
end
echo "$extension files under $root with >= $big_linecount lines:"
find $root -name '*.'$extension -print0 | xargs -0 wc -l | sort -rn \
| awk '/^ *total/{/*d*/} // { if ($1 > '$big_linecount') { print($0); } }'
end
@randomstep
Copy link

Using something like cloc and only counting source code lines could be better, in that this could inadvertently discourage commenting if used as part of a toolchain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment