From 0b3d06a3f9ca6d1e4a3f8a2be7145ff90509ede6 Mon Sep 17 00:00:00 2001 From: MorganGeek Date: Sun, 12 Jul 2020 22:55:16 +0200 Subject: [PATCH] move reusable code bricks to aliases/functions - new aliases to be used in pipes --- dot_zsh_aliases | 2 ++ dot_zsh_functions | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dot_zsh_aliases b/dot_zsh_aliases index 4e51f4f..7eaf10b 100644 --- a/dot_zsh_aliases +++ b/dot_zsh_aliases @@ -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' diff --git a/dot_zsh_functions b/dot_zsh_functions index 57f1e47..8d70c02 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -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" {} \;