From f0aa65ef5601bd7d7c081397c6814200cef56176 Mon Sep 17 00:00:00 2001 From: MorganGeek Date: Wed, 8 Jul 2020 16:59:29 +0200 Subject: [PATCH] add filtering for top commands output --- dot_zsh_functions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dot_zsh_functions b/dot_zsh_functions index 9836f83..94d9883 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -96,10 +96,12 @@ function git_listobjectsbysize() { rm -f "$tempFile" } function top_commands() { - history | \cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n50 + local filter="$1" + history | \cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | grep "$filter" | sort -nr | nl | head -n50 } function top_commands_full() { - history | \cat | awk '{$1=$1};1' | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | sort -nr | nl | head -n50 + local filter="$1" + history | \cat | awk '{$1=$1};1' | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | grep "$filter" | sort -nr | nl | head -n50 } function istherenewissues() { LASTISSUE=$(newissues | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' | awk 'FNR==2{print $2}')