home
/
code
/
khome.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0a06131
)
Implement top_commands function
author
Siraaj Khandkar
<siraaj@khandkar.net>
Sun, 22 Dec 2019 16:07:57 +0000
(11:07 -0500)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Sun, 22 Dec 2019 16:07:57 +0000
(11:07 -0500)
home/lib/login_functions.sh
patch
|
blob
|
blame
|
history
diff --git
a/home/lib/login_functions.sh
b/home/lib/login_functions.sh
index
163c09e
..
e006eee
100644
(file)
--- a/
home/lib/login_functions.sh
+++ b/
home/lib/login_functions.sh
@@
-5,6
+5,40
@@
d() {
dict "$word"
}
dict "$word"
}
+top_commands() {
+ history \
+ | awk '
+ {
+ count[$4]++
+ }
+
+ END {
+ for (cmd in count)
+ print count[cmd], cmd
+ }' \
+ | sort -n -r -k 1 \
+ | head -50 \
+ | awk '
+ {
+ cmd[NR] = $2
+ c = count[NR] = $1 + 0 # + 0 to coerce number from string
+ if (c > max)
+ max = c
+ }
+
+ END {
+ for (i = 1; i <= NR; i++) {
+ c = count[i]
+ printf "%s %d ", cmd[i], c
+ scaled = (c * 100) / max
+ for (j = 1; j <= scaled; j++)
+ printf "|"
+ printf "\n"
+ }
+ }' \
+ | column -t
+}
+
# Top Disk-Using directories
# TODO: Consider using numfmt instead of awk
tdu() {
# Top Disk-Using directories
# TODO: Consider using numfmt instead of awk
tdu() {
This page took
0.022589 seconds
and
4
git commands to generate.