- disk usage (file sizes) (aka ncdu alternative)
- git commits count per file
- lines of code, comments, blank lines (with tokei)
- lines count, words count (with coreutils
wc
) - matches count per file
- files count in directory
disk usage (file sizes) (aka ncdu alternative)
fd -HI -tf --strip-cwd-prefix --exec-batch du -b --apparent-size \
| nctok --number-delimiter $'\t'
git log --name-only --format="" \
| grep -v '^$' \
| perl -lne 'print if -e' \
| sort | uniq -c | sed 's/^\s*//' | nctok
lines of code, comments, blank lines (with tokei)
_tokei_helper() {
target="$1"; shift
tokei -Cfo json $* \
| jq -r '.[].reports[] | "\(.stats.'$target') \(.name)"' \
| nctok
}
# by code
alias bycode="_tokei_helper code"
# by comments
alias bycmnts="_tokei_helper comments"
# by blanks
alias byblanks="_tokei_helper blanks"
Also, tokei supports filtering by language (read more in tokei's help), and we can pass it to our aliases:
bycode -t c++
bycode -t shell
bycode -t c++,rust
# by lines
fd -HI -tf --strip-cwd-prefix --exec-batch wc -l --total=never \
| sed 's/^\s*//' | nctok
# by words
fd -HI -tf --strip-cwd-prefix --exec-batch wc -w --total=never \
| sed 's/^\s*//' | nctok
rg "your_pattern" --count-matches --null | awk -F '\0' '{print $2, $1}' | nctok
(actually just adding "1" for each file)
fd -tf | sed 's/^/1 /' | nctok