From: Siraaj Khandkar Date: Sun, 22 Dec 2019 16:19:43 +0000 (-0500) Subject: Implement shell_activity_report function X-Git-Url: https://git.xandkar.net/?p=khome.git;a=commitdiff_plain;h=94df2def5a3ab95bca8cdef99301d1cc39b8cab1 Implement shell_activity_report function --- diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index e006eee..87746c6 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -5,6 +5,31 @@ d() { dict "$word" } +shell_activity_report() { + history \ + | awk ' + { + time = $3 + ok = split(time, t, ":") + if (ok) { + hour = t[1] + 0 # Coerce number from string + cnt = count[hour]++ + } + if (cnt > max) + max = cnt + } + + END { + for (hour=0; hour<24; hour++) { + c = count[hour] + printf "%2d ", hour + for (i=1; i<=((c * 100) / max); i++) + printf "|" + printf "\n" + } + }' +} + top_commands() { history \ | awk '