move reusable code bricks to aliases/functions

- new aliases to be used in pipes
This commit is contained in:
MorganGeek 2020-07-12 22:55:16 +02:00
parent 858eebdb91
commit 0b3d06a3f9
2 changed files with 5 additions and 3 deletions

View File

@ -80,6 +80,8 @@ alias hist='history'
alias codestats='tokei'
alias dups='file_dups'
alias pairs='file_getpairs'
alias filter_pairs="tr '[:upper:]' '[:lower:]' | \grep -o -E '\w{3,} \w{3,}' | \grep --invert-match --word-regexp --fixed-strings --file=\"\$HOME/stopwords.txt\" | \sed 's/s$//g' | \sed 's/ing$//g' | sort | uniq -c | sort --numeric-sort --reverse"
alias sort_count="sort | uniq -c | sort --numeric-sort --reverse"
alias words='file_getwords'
alias fd="\fd"
alias wiki='wikit'

View File

@ -467,14 +467,14 @@ function dl_stopwords() {
}
function file_getwords() {
dl_stopwords
\cat "$1" | tr '[:upper:]' '[:lower:]' | \grep -o -E '\w{3,}' | \grep --invert-match --word-regexp --fixed-strings --file="$HOME/stopwords.txt" | \sed 's/s$//g' | \sed 's/ing$//g' | sort | uniq -c | sort --numeric-sort --reverse
\cat "$1" | tr '[:upper:]' '[:lower:]' | \grep -o -E '\w{3,}' | \grep --invert-match --word-regexp --fixed-strings --file="$HOME/stopwords.txt" | \sed 's/s$//g' | \sed 's/ing$//g' | sort_count
}
function file_getpairs() {
dl_stopwords
\cat "$1" | tr '[:upper:]' '[:lower:]' | \grep -o -E '\w{3,} \w{3,}' | \grep --invert-match --word-regexp --fixed-strings --file="$HOME/stopwords.txt" | \sed 's/s$//g' | \sed 's/ing$//g' | sort | uniq -c | sort --numeric-sort --reverse
\cat "$1" | filter_pairs
}
function file_dups() {
\cat "$1" | sort | uniq -c | sort -nr
\cat "$1" | sort_count
}
function foreach_run() {
find . -name "$1" -exec "$2" {} \;