Add exit code and log msg based on number of found records
[khome.git] / home / lib / login_functions.sh
1 #
2
3 ## p : string -> unit
4 p() {
5 awk \
6 -v _s="$1" \
7 '
8 BEGIN {_s = tolower(_s)}
9
10 # TODO fzf/dmenu select instead of searching:
11 /^[a-zA-Z]/ && tolower($1) ~ _s && NF >= 2 {
12 n++
13 s = $1
14 p = $NF
15 if (NF == 2) {
16 e = ""
17 u = ""
18 } else if (NF == 3) {
19 e = $2
20 u = ""
21 } else {
22 e = $2
23 u = $3
24 } # TODO What would NF > 4 mean?
25
26 printf("%d [O] s:\"%s\", e:\"%s\", u:\"%s\"\n", n, s, e, u) > "/dev/stderr"
27 if (match(u, "@")) {
28 tmp = e
29 e = u
30 u = tmp
31 printf("%d [C] s:\"%s\", e:\"%s\", u:\"%s\"\n", n, s, e, u) > "/dev/stderr"
32 }
33
34 printf "%s", p # XXX Intentionally avoiding newline in the result.
35 }
36
37 END {
38 if (n == 1) {
39 exit 0
40 } else if (n == 0) {
41 printf "[ERROR] Found nothing.\n" > "/dev/stderr"
42 exit 1
43 } else if (n > 1) {
44 # TODO fzf-select which of the records the user (ahem, me) wants.
45 printf "[WARNING] Found more than one record.\n" > "/dev/stderr"
46 exit 0
47 }
48 }
49 ' \
50 ~/._p/p \
51 | xsel -i -b -t 30000
52 }
53
54 ## web search
55 ## ws : string -> unit
56 ws() {
57 local line search_string0 search_string
58
59 search_string0="$*"
60 case "$search_string0" in
61 '')
62 while read -r line; do
63 search_string="${search_string} ${line}"
64 done;;
65 *)
66 search_string="$search_string0";;
67 esac
68
69 firefox --search "$search_string"
70 }
71
72
73 ## dictionary
74 ## d : string -> string list
75 d() {
76 local -r word=$(fzf < /usr/share/dict/words)
77 dict "$word"
78 }
79
80 ## shell_activity_report : (mon | dow) -> string list
81 shell_activity_report() {
82 # TODO: optional concrete number output
83 # TODO: optional combinations of granularities: hour, weekday, month, year
84 local group_by="$1"
85 case "$group_by" in
86 'mon') ;;
87 'dow') ;;
88 '') group_by='dow';;
89 *)
90 echo "Usage: $0 [mon|dow]" >&2
91 kill -INT $$
92 esac
93 history \
94 | awk -v group_by="$group_by" '
95 function date2dow(y, m, d, _t, _i) {
96 # Contract:
97 # y > 1752, 1 <= m <= 12.
98 # Source:
99 # Sakamoto`s methods
100 # https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto%27s_methods
101 _t[ 0] = 0
102 _t[ 1] = 3
103 _t[ 2] = 2
104 _t[ 3] = 5
105 _t[ 4] = 0
106 _t[ 5] = 3
107 _t[ 6] = 5
108 _t[ 7] = 1
109 _t[ 8] = 4
110 _t[ 9] = 6
111 _t[10] = 2
112 _t[11] = 4
113 y -= m < 3
114 _i = int(y + y/4 - y/100 + y/400 + _t[m - 1] + d) % 7
115 _i = _i == 0 ? 7 : _i # Make Sunday last
116 return _i
117
118 }
119
120 {
121 # NOTE: $2 & $3 are specific to oh-my-zsh history output
122 date = $2
123 time = $3
124 d_fields = split(date, d, "-")
125 t_fields = split(time, t, ":")
126 if (t_fields && d_fields) {
127 # +0 to coerce number from string
128 year = d[1] + 0
129 month = d[2] + 0
130 day = d[3] + 0
131 hour = t[1] + 0
132 dow = date2dow(year, month, day)
133 g = group_by == "mon" ? month : dow # dow is default
134 c = count[g, hour]++
135 }
136 if (c > max)
137 max = c
138 }
139
140 END {
141 w[1] = "Monday"
142 w[2] = "Tuesday"
143 w[3] = "Wednesday"
144 w[4] = "Thursday"
145 w[5] = "Friday"
146 w[6] = "Saturday"
147 w[7] = "Sunday"
148
149 m[ 1] = "January"
150 m[ 2] = "February"
151 m[ 3] = "March"
152 m[ 4] = "April"
153 m[ 5] = "May"
154 m[ 6] = "June"
155 m[ 7] = "July"
156 m[ 8] = "August"
157 m[ 9] = "September"
158 m[10] = "October"
159 m[11] = "November"
160 m[12] = "December"
161
162 n = group_by == "mon" ? 12 : 7 # dow is default
163
164 for (gid = 1; gid <= n; gid++) {
165 group = group_by == "mon" ? m[gid] : w[gid]
166 printf "%s\n", group;
167 for (hour=0; hour<24; hour++) {
168 c = count[gid, hour]
169 printf " %2d ", hour
170 for (i = 1; i <= (c * 100) / max; i++)
171 printf "|"
172 printf "\n"
173 }
174 }
175 }'
176 }
177
178 ## top_commands : unit -> (command:string * count:number * bar:string) list
179 top_commands() {
180 history \
181 | awk '
182 {
183 count[$4]++
184 }
185
186 END {
187 for (cmd in count)
188 print count[cmd], cmd
189 }' \
190 | sort -n -r -k 1 \
191 | head -50 \
192 | awk '
193 {
194 cmd[NR] = $2
195 c = count[NR] = $1 + 0 # + 0 to coerce number from string
196 if (c > max)
197 max = c
198 }
199
200 END {
201 for (i = 1; i <= NR; i++) {
202 c = count[i]
203 printf "%s %d ", cmd[i], c
204 scaled = (c * 100) / max
205 for (j = 1; j <= scaled; j++)
206 printf "|"
207 printf "\n"
208 }
209 }' \
210 | column -t
211 }
212
213 ## Top Disk-Using directories
214 ## TODO: Consider using numfmt instead of awk
215 ## tdu : path-string -> (size:number * directory:path-string) list
216 tdu() {
217 local -r root_path="$1"
218
219 du "$root_path" \
220 | awk '
221 {
222 size = $1
223 path = $0
224 sub("^" $1 "\t+", "", path)
225 paths[path] = size
226 if (size > max)
227 max = size
228 }
229
230 END {
231 for (path in paths) {
232 size = paths[path]
233 pct = 100 * (size / max)
234 gb = size / 1024 / 1024
235 printf("%6.2f %3d%% %s\n", gb, pct, path)
236 }
237 }
238 ' \
239 | sort -r -n -k 1 \
240 | head -50 \
241 | tac
242 # A slight optimization: head can exit before traversing the full input.
243 }
244
245 ## Top Disk-Using Files
246 ## tduf : path-string list -> (size:number * file:path-string) list
247 tduf() {
248 find "$@" -type f -printf '%s\t%p\0' \
249 | sort -z -n -k 1 \
250 | tail -z -n 50 \
251 | gawk -v RS='\0' '
252 {
253 size = $1
254 path = $0
255 sub("^" $1 "\t+", "", path)
256 gb = size / 1024 / 1024 / 1024
257 printf("%f\t%s\n", gb, path)
258 }'
259 }
260
261 # Most-recently modified file system objects
262 ## recent : ?(path-string list) -> path-string list
263 recent() {
264 # NOTES:
265 # - %T+ is a GNU extension;
266 # - gawk is able to split records on \0, while awk cannot.
267 find "$@" -printf '%T@ %T+ %p\0' \
268 | tee >(gawk -v RS='\0' 'END { printf("[INFO] Total found: %d\n", NR); }') \
269 | sort -z -k 1 -n -r \
270 | head -n "$(stty size | awk 'NR == 1 {print $1 - 5}')" -z \
271 | gawk -v RS='\0' '
272 {
273 sub("^" $1 " +", "") # Remove epoch time
274 sub("+", " ") # Blank-out the default separator
275 sub("\\.[0-9]+", "") # Remove fractional seconds
276 print
277 }'
278 }
279
280 ## recent_dirs : ?(path-string list) -> path-string list
281 recent_dirs() {
282 recent "$@" -type d
283 }
284
285 ## recent_files : ?(path-string list) -> path-string list
286 recent_files() {
287 recent "$@" -type f
288 }
289
290 ## pa_def_sink : unit -> string
291 pa_def_sink() {
292 pactl info | awk '/^Default Sink:/ {print $3}'
293 }
294
295 ## void_pkgs : ?(string) -> json
296 void_pkgs() {
297 curl "https://xq-api.voidlinux.org/v1/query/x86_64?q=$1" | jq '.data'
298 }
299
300 ## Colorful man
301 ## man : string -> string
302 man() {
303 # mb: begin blink
304 # md: begin bold
305 # me: end bold, blink and underline
306 #
307 # so: begin standout (reverse video)
308 # se: end standout
309 #
310 # us: begin underline
311 # ue: end underline
312
313 LESS_TERMCAP_md=$'\e[01;30m' \
314 LESS_TERMCAP_me=$'\e[0m' \
315 LESS_TERMCAP_so=$'\e[01;44;33m' \
316 LESS_TERMCAP_se=$'\e[0m' \
317 LESS_TERMCAP_us=$'\e[01;33m' \
318 LESS_TERMCAP_ue=$'\e[0m' \
319 command man "$@"
320 }
321
322 ## new experiment
323 ## x : string list -> unit
324 x() {
325 cd "$(~/bin/x $@)" || kill -INT $$
326 }
327
328 ## ocaml repl
329 ## hump : unit -> unit
330 hump() {
331 ledit -l "$(stty size | awk '{print $2}')" ocaml $@
332 }
333
334 ## search howtos
335 ## howto : unit -> string
336 howto() {
337 cat "$(find ~/arc/doc/HOWTOs -mindepth 1 -maxdepth 1 | sort | fzf)"
338 }
339
340 _yt() {
341 local -r base_dir="$1"
342 local -r uri="$2"
343 local -r opts="$3"
344
345 local -r id=$(youtube-dlc --get-id "$uri")
346 local -r title=$(youtube-dlc --get-title "$uri" | sed 's/[^А-Яа-яA-Za-z0-9._-]/_/g')
347 local -r dir="${base_dir}/${title}--${id}"
348
349 mkdir -p "$dir"
350 cd "$dir" || kill -INT $$
351 echo "$uri" > 'uri'
352 youtube-dlc $opts -c --write-all-thumbnails --write-description --write-info-json "$uri"
353 }
354
355 yt_audio() {
356 local -r uri="$1"
357 _yt "${DIR_YOUTUBE_AUDIO}/individual" "$uri" '-f 140'
358 }
359
360 yt_video() {
361 local -r uri="$1"
362 _yt "${DIR_YOUTUBE_VIDEO}/individual" "$uri"
363 }
364
365 gh_fetch_repos() {
366 local -r user_type="$1"
367 local -r user_name="$2"
368
369 curl "https://api.github.com/$user_type/$user_name/repos?page=1&per_page=10000"
370 }
371
372 gh_clone() {
373 local -r gh_user_type="$1"
374 local -r gh_user_name="$2"
375
376 local -r gh_dir="${DIR_GITHUB}/${gh_user_name}"
377 mkdir -p "$gh_dir"
378 cd "$gh_dir" || kill -INT $$
379 gh_fetch_repos "$gh_user_type" "$gh_user_name" \
380 | jq --raw-output '.[] | select(.fork | not) | .clone_url' \
381 | parallel -j 25 \
382 git clone {}
383 }
384
385 gh_clone_user() {
386 gh_clone 'users' "$1"
387 }
388
389 gh_clone_org() {
390 gh_clone 'orgs' "$1"
391 }
392
393 gh_clone_repo() {
394 gh_username=$(echo "$1" | awk -F / '"$1 == "https" && $3 == github.com" {print $4}')
395 gh_dir="${DIR_GITHUB}/${gh_username}"
396 mkdir -p "$gh_dir"
397 cd "$gh_dir" || kill -INT $$
398 git clone "$1"
399 }
400
401 work_log_template() {
402 cat << EOF
403 $(date '+%F %A')
404 ==========
405
406 Morning report
407 --------------
408
409 ### Prev
410
411 ### Curr
412
413 ### Next
414
415 ### Blockers
416
417 Day's notes
418 -----------
419 EOF
420 }
421
422 work_log() {
423 mkdir -p "$DIR_WORK_LOG"
424 local -r file_work_log_today="${DIR_WORK_LOG}/daily-$(date +%F).md"
425 if [ ! -f "$file_work_log_today" ]
426 then
427 work_log_template > "$file_work_log_today"
428 fi
429 vim -c 'set spell' "$file_work_log_today"
430
431 }
432
433 note() {
434 mkdir -p "$DIR_NOTES"
435 vim -c 'set spell' "$DIR_NOTES/$(date +'%Y_%m_%d--%H_%M_%S%z')--$1.md"
436 }
437
438 _bt_devs_infos() {
439 # grep's defintion of a line does not include \r, wile awk's does and
440 # which bluetoothctl outputs
441 awk '/^Device +/ {print $2}' \
442 | xargs -I% sh -c 'echo info % | bluetoothctl' \
443 | awk '/^Device |^\t[A-Z][A-Za-z0-9]+: /'
444 }
445
446 bt_devs_paired() {
447 echo 'paired-devices' | bluetoothctl | _bt_devs_infos
448 }
449
450 bt_devs() {
451 echo 'devices' | bluetoothctl | _bt_devs_infos
452 }
453
454 run() {
455 local -r stderr="$(mktemp)"
456
457 local code urgency
458
459 $@ 2> >(tee "$stderr")
460 code="$?"
461 case "$code" in
462 0) urgency='normal';;
463 *) urgency='critical'
464 esac
465 notify-send -u "$urgency" "Job done: $code" "$(cat $stderr)"
466 rm "$stderr"
467 }
468
469 bar_gauge() {
470 awk "$@" '
471 BEGIN {
472 # CLI options
473 width = width ? width : 80
474 ch_left = ch_left ? ch_left : "["
475 ch_right = ch_right ? ch_right : "]"
476 ch_blank = ch_blank ? ch_blank : "-"
477 ch_used = ch_used ? ch_used : "|"
478 num = num ? 1 : 0
479 pct = pct ? 1 : 0
480 }
481
482 {
483 cur = $1
484 max = $2
485 lab = $3
486
487 cur_scaled = num_scale(cur, max, 1, width)
488
489 printf \
490 "%s%s%s%s", \
491 lab ? lab " " : "", \
492 num ? cur "/" max " " : "", \
493 pct ? sprintf("%3.0f%% ", cur / max * 100) : "", \
494 ch_left
495 for (i=1; i<=width; i++) {
496 c = i <= cur_scaled ? ch_used : ch_blank
497 printf "%s", c
498 }
499 printf "%s\n", ch_right
500 }
501
502 function num_scale(src_cur, src_max, dst_min, dst_max) {
503 return dst_min + ((src_cur * (dst_max - dst_min)) / src_max)
504 }
505 '
506 }
507
508 flat_top_5() {
509 sort -n -k 1 -r \
510 | head -5 \
511 | awk '
512 {
513 cur = $1
514 max = $2
515 name = $3
516 pct = cur / max * 100
517 printf "%s%s %.2f%%", sep, name, pct
518 sep = ", "
519 }
520
521 END {printf "\n"}
522 '
523 }
524
525 internet_addr() {
526 curl --silent --show-error --max-time "${1:=1}" 'https://api.ipify.org' 2>&1
527 }
528
529 status_batt() {
530 case "$(uname)" in
531 'Linux')
532 if which upower > /dev/null
533 then
534 upower --dump \
535 | awk '
536 /^Device:[ \t]+/ {
537 device["path"] = $2
538 next
539 }
540
541 / battery/ && device["path"] {
542 device["is_battery"] = 1
543 next
544 }
545
546 / percentage:/ && device["is_battery"] {
547 device["battery_percentage"] = $2
548 sub("%$", "", device["battery_percentage"])
549 next
550 }
551
552 /^$/ {
553 if (device["is_battery"] && device["path"] == "/org/freedesktop/UPower/devices/DisplayDevice")
554 print device["battery_percentage"], 100, "batt"
555 delete device
556 }
557 '
558 fi
559 ;;
560 esac
561 }
562
563 indent() {
564 awk -v unit="$1" '{printf "%s%s\n", unit, $0}'
565 }
566
567 status() {
568 local -r indent_unit=' '
569
570 uname -srvmo
571 hostname | figlet
572 uptime
573
574 echo
575
576 echo 'accounting'
577
578 printf '%stmux\n%ssessions %d, clients %d\n' \
579 "$indent_unit" \
580 "${indent_unit}${indent_unit}" \
581 "$(tmux list-sessions 2> /dev/null | wc -l)" \
582 "$(tmux list-clients 2> /dev/null | wc -l)"
583
584 echo
585
586 printf '%sprocs by user\n' "${indent_unit}"
587 ps -eo user \
588 | awk '
589 NR > 1 {
590 count_by_user[$1]++
591 total++
592 }
593
594 END {
595 for (user in count_by_user)
596 print count_by_user[user], total, user
597 }
598 ' \
599 | flat_top_5 \
600 | indent "${indent_unit}${indent_unit}"
601
602 echo
603
604 echo 'resources'
605 (
606 free | awk '$1 == "Mem:" {print $3, $2, "mem"}'
607 df ~ | awk 'NR == 2 {print $3, $3 + $4, "disk"}'
608 status_batt
609 ) \
610 | bar_gauge -v width=60 -v pct=1 \
611 | column -t \
612 | indent "$indent_unit"
613
614 echo
615
616 printf '%smem by proc\n' "$indent_unit"
617 ps -eo rss,comm \
618 | awk -v total="$(free | awk '$1 == "Mem:" {print $2; exit}')" '
619 NR > 1 {
620 rss = $1
621 proc = $2
622 by_proc[proc] += rss
623 }
624
625 END {
626 for (proc in by_proc)
627 print by_proc[proc], total, proc
628 }
629 ' \
630 | flat_top_5 \
631 | indent "${indent_unit}${indent_unit}"
632
633 echo
634
635 local _dir temp_input label_file label
636
637 printf '%sthermal\n' "$indent_unit"
638 for _dir in /sys/class/hwmon/hwmon*; do
639 cat "$_dir"/name
640 find "$_dir"/ -name 'temp*_input' \
641 | while read -r temp_input; do
642 label_file=${temp_input//_input/_label}
643 if [ -f "$label_file" ]; then
644 label=$(< "$label_file")
645 else
646 label=''
647 fi
648 awk -v label="$label" '{
649 if (label)
650 label = sprintf(" (%s)", label)
651 printf("%.2f°C%s\n", $1 / 1000, label)
652 }' \
653 "$temp_input"
654 done \
655 | sort \
656 | indent "$indent_unit"
657 done \
658 | indent "${indent_unit}${indent_unit}"
659
660 echo 'net'
661 #local -r internet_addr=$(internet_addr 0.5)
662 #local -r internet_ptr=$(host -W 1 "$internet_addr" | awk 'NR == 1 {print $NF}' )
663
664 #echo "${indent_unit}internet"
665 #echo "${indent_unit}${indent_unit}$internet_addr $internet_ptr"
666 echo "${indent_unit}if"
667 (ifconfig; iwconfig) 2> /dev/null \
668 | awk '
669 /^[^ ]/ {
670 device = $1
671 sub(":$", "", device)
672 if ($4 ~ "ESSID:") {
673 _essid = $4
674 sub("^ESSID:\"", "", _essid)
675 sub("\"$", "", _essid)
676 essid[device] = _essid
677 }
678 next
679 }
680
681 /^ / && $1 == "inet" {
682 address[device] = $2
683 next
684 }
685
686 /^ +Link Quality=[0-9]+\/[0-9]+ +Signal level=/ {
687 split($2, lq_parts_eq, "=")
688 split(lq_parts_eq[2], lq_parts_slash, "/")
689 cur = lq_parts_slash[1]
690 max = lq_parts_slash[2]
691 link[device] = cur / max * 100
692 next
693 }
694
695 END {
696 for (device in address)
697 if (device != "lo") {
698 l = link[device]
699 e = essid[device]
700 l = l ? sprintf("%.0f%%", l) : "--"
701 e = e ? e : "--"
702 print device, address[device], e, l
703 }
704 }
705 ' \
706 | column -t \
707 | indent "${indent_unit}${indent_unit}"
708
709 # WARN: ensure: $USER ALL=(ALL) NOPASSWD:/bin/netstat
710
711 echo "${indent_unit}-->"
712
713 sudo -n netstat -tulnp \
714 | awk -v indent="${indent_unit}${indent_unit}" '
715 NR > 2 && ((/^tcp/ && proc = $7) || (/^udp/ && proc = $6)) {
716 protocol = $1
717 addr = $4
718 port = a[split(addr, a, ":")]
719 name = p[split(proc, p, "/")]
720 names[name] = 1
721 protocols[protocol] = 1
722 if (!seen[protocol, name, port]++)
723 ports[protocol, name, ++seen[protocol, name]] = port
724 }
725
726 END {
727 for (protocol in protocols) {
728 printf "%s%s\t", indent, toupper(protocol)
729 for (name in names) {
730 if (n = seen[protocol, name]) {
731 sep = ""
732 printf "%s:", name
733 for (i = 1; i <= n; i++) {
734 printf "%s%d", sep, ports[protocol, name, i]
735 sep = ","
736 }
737 printf " "
738 }
739 }
740 printf "\n"
741 }
742 }'
743
744 echo "${indent_unit}<->"
745
746 printf '%sTCP\t' "${indent_unit}${indent_unit}"
747 sudo -n netstat -tnp \
748 | awk 'NR > 2 && $6 == "ESTABLISHED" {print $7}' \
749 | awk '{sub("^[0-9]+/", ""); print}' \
750 | sort -u \
751 | xargs \
752 | column -t
753
754 # TODO: iptables summary
755 }
756
757 ssh_invalid_by_addr() {
758 awk '
759 /: Invalid user/ && $5 ~ /^sshd/ {
760 addr=$10 == "port" ? $9 : $10
761 max++
762 by_addr[addr]++
763 }
764
765 END {
766 for (addr in by_addr)
767 if ((c = by_addr[addr]) > 1)
768 printf "%d %d %s\n", c, max, addr
769 }
770 ' \
771 /var/log/auth.log \
772 /var/log/auth.log.1 \
773 | sort -n -k 1 \
774 | bar_gauge -v width="$(stty size | awk '{print $2}')" -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
775 | column -t
776 }
777
778 ssh_invalid_by_day() {
779 awk '
780 BEGIN {
781 m["Jan"] = "01"
782 m["Feb"] = "02"
783 m["Mar"] = "03"
784 m["Apr"] = "04"
785 m["May"] = "05"
786 m["Jun"] = "06"
787 m["Jul"] = "07"
788 m["Aug"] = "08"
789 m["Sep"] = "09"
790 m["Oct"] = "10"
791 m["Nov"] = "11"
792 m["Dec"] = "12"
793 }
794
795 /: Invalid user/ && $5 ~ /^sshd/ {
796 day = m[$1] "-" $2
797 max++
798 by_day[day]++
799 }
800
801 END {
802 for (day in by_day)
803 if ((c = by_day[day]) > 1)
804 printf "%d %d %s\n", c, max, day
805 }
806 ' \
807 /var/log/auth.log \
808 /var/log/auth.log.1 \
809 | sort -k 3 \
810 | bar_gauge -v width="$(stty size | awk '{print $2}')" -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
811 | column -t
812 }
813
814 ssh_invalid_by_user() {
815 awk '
816 /: Invalid user/ && $5 ~ /^sshd/ {
817 user=$8
818 max++
819 by_user[user]++
820 }
821
822 END {
823 for (user in by_user)
824 if ((c = by_user[user]) > 1)
825 printf "%d %d %s\n", c, max, user
826 }
827 ' \
828 /var/log/auth.log \
829 /var/log/auth.log.1 \
830 | sort -n -k 1 \
831 | bar_gauge -v width="$(stty size | awk '{print $2}')" -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
832 | column -t
833 }
834
835 loggers() {
836 awk '
837 {
838 split($5, prog, "[")
839 sub(":$", "", prog[1]) # if there were no [], than : will is left behind
840 print prog[1]
841 }' /var/log/syslog /var/log/syslog.1 \
842 | awk '
843 {
844 n = split($1, path, "/") # prog may be in path form
845 prog = path[n]
846 total++
847 count[prog]++
848 }
849
850 END {
851 for (prog in count)
852 print count[prog], total, prog
853 }' \
854 | sort -n -k 1 \
855 | bar_gauge -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
856 | column -t
857 }
This page took 0.226475 seconds and 5 git commands to generate.