Implement shell_activity_report function
authorSiraaj Khandkar <siraaj@khandkar.net>
Sun, 22 Dec 2019 16:19:43 +0000 (11:19 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sun, 22 Dec 2019 16:19:43 +0000 (11:19 -0500)
home/lib/login_functions.sh

index e006eee..87746c6 100644 (file)
@@ -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 '
This page took 0.0304 seconds and 4 git commands to generate.