Replace youtube-dl packages with a manual recipe
[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 yt=youtube-dl
346 local -r id=$("$yt" --get-id "$uri")
347 local -r title=$("$yt" --get-title "$uri" | sed 's/[^А-Яа-яA-Za-z0-9._-]/_/g')
348 local -r dir="${base_dir}/${title}--${id}"
349
350 mkdir -p "$dir"
351 cd "$dir" || kill -INT $$
352 echo "$uri" > 'uri'
353 "$yt" $opts -c --write-all-thumbnails --write-description --write-info-json "$uri"
354 }
355
356 yt_audio() {
357 local -r uri="$1"
358 _yt "${DIR_YOUTUBE_AUDIO}/individual" "$uri" '-f 140'
359 }
360
361 yt_video() {
362 local -r uri="$1"
363 _yt "${DIR_YOUTUBE_VIDEO}/individual" "$uri"
364 }
365
366 gh_fetch_repos() {
367 local -r user_type="$1"
368 local -r user_name="$2"
369
370 curl "https://api.github.com/$user_type/$user_name/repos?page=1&per_page=10000"
371 }
372
373 gh_clone() {
374 local -r gh_user_type="$1"
375 local -r gh_user_name="$2"
376
377 local -r gh_dir="${DIR_GITHUB}/${gh_user_name}"
378 mkdir -p "$gh_dir"
379 cd "$gh_dir" || kill -INT $$
380 gh_fetch_repos "$gh_user_type" "$gh_user_name" \
381 | jq --raw-output '.[] | select(.fork | not) | .clone_url' \
382 | parallel -j 25 \
383 git clone {}
384 }
385
386 gh_clone_user() {
387 gh_clone 'users' "$1"
388 }
389
390 gh_clone_org() {
391 gh_clone 'orgs' "$1"
392 }
393
394 gh_clone_repo() {
395 gh_username=$(echo "$1" | awk -F / '"$1 == "https" && $3 == github.com" {print $4}')
396 gh_dir="${DIR_GITHUB}/${gh_username}"
397 mkdir -p "$gh_dir"
398 cd "$gh_dir" || kill -INT $$
399 git clone "$1"
400 }
401
402 work_log_template() {
403 cat << EOF
404 $(date '+%F %A')
405 ==========
406
407 Morning report
408 --------------
409
410 ### Prev
411
412 ### Curr
413
414 ### Next
415
416 ### Blockers
417
418 Day's notes
419 -----------
420 EOF
421 }
422
423 work_log() {
424 mkdir -p "$DIR_WORK_LOG"
425 local -r file_work_log_today="${DIR_WORK_LOG}/daily-$(date +%F).md"
426 if [ ! -f "$file_work_log_today" ]
427 then
428 work_log_template > "$file_work_log_today"
429 fi
430 vim -c 'set spell' "$file_work_log_today"
431
432 }
433
434 note() {
435 mkdir -p "$DIR_NOTES"
436 vim -c 'set spell' "$DIR_NOTES/$(date +'%Y_%m_%d--%H_%M_%S%z')--$1.md"
437 }
438
439 _bt_devs_infos() {
440 # grep's defintion of a line does not include \r, wile awk's does and
441 # which bluetoothctl outputs
442 awk '/^Device +/ {print $2}' \
443 | xargs -I% sh -c 'echo info % | bluetoothctl' \
444 | awk '/^Device |^\t[A-Z][A-Za-z0-9]+: /'
445 }
446
447 bt_devs_paired() {
448 echo 'paired-devices' | bluetoothctl | _bt_devs_infos
449 }
450
451 bt_devs() {
452 echo 'devices' | bluetoothctl | _bt_devs_infos
453 }
454
455 run() {
456 local -r stderr="$(mktemp)"
457
458 local code urgency
459
460 $@ 2> >(tee "$stderr")
461 code="$?"
462 case "$code" in
463 0) urgency='normal';;
464 *) urgency='critical'
465 esac
466 notify-send -u "$urgency" "Job done: $code" "$(cat $stderr)"
467 rm "$stderr"
468 }
469
470 bar_gauge() {
471 awk "$@" '
472 BEGIN {
473 # CLI options
474 width = width ? width : 80
475 ch_left = ch_left ? ch_left : "["
476 ch_right = ch_right ? ch_right : "]"
477 ch_blank = ch_blank ? ch_blank : "-"
478 ch_used = ch_used ? ch_used : "|"
479 num = num ? 1 : 0
480 pct = pct ? 1 : 0
481 }
482
483 {
484 cur = $1
485 max = $2
486 lab = $3
487
488 cur_scaled = num_scale(cur, max, 1, width)
489
490 printf \
491 "%s%s%s%s", \
492 lab ? lab " " : "", \
493 num ? cur "/" max " " : "", \
494 pct ? sprintf("%3.0f%% ", cur / max * 100) : "", \
495 ch_left
496 for (i=1; i<=width; i++) {
497 c = i <= cur_scaled ? ch_used : ch_blank
498 printf "%s", c
499 }
500 printf "%s\n", ch_right
501 }
502
503 function num_scale(src_cur, src_max, dst_min, dst_max) {
504 return dst_min + ((src_cur * (dst_max - dst_min)) / src_max)
505 }
506 '
507 }
508
509 flat_top_5() {
510 sort -n -k 1 -r \
511 | head -5 \
512 | awk '
513 {
514 cur = $1
515 max = $2
516 name = $3
517 pct = cur / max * 100
518 printf "%s%s %.2f%%", sep, name, pct
519 sep = ", "
520 }
521
522 END {printf "\n"}
523 '
524 }
525
526 internet_addr() {
527 curl --silent --show-error --max-time "${1:=1}" 'https://api.ipify.org' 2>&1
528 }
529
530 status_batt() {
531 case "$(uname)" in
532 'Linux')
533 if which upower > /dev/null
534 then
535 upower --dump \
536 | awk '
537 /^Device:[ \t]+/ {
538 device["path"] = $2
539 next
540 }
541
542 / battery/ && device["path"] {
543 device["is_battery"] = 1
544 next
545 }
546
547 / percentage:/ && device["is_battery"] {
548 device["battery_percentage"] = $2
549 sub("%$", "", device["battery_percentage"])
550 next
551 }
552
553 /^$/ {
554 if (device["is_battery"] && device["path"] == "/org/freedesktop/UPower/devices/DisplayDevice")
555 print device["battery_percentage"], 100, "batt"
556 delete device
557 }
558 '
559 fi
560 ;;
561 esac
562 }
563
564 indent() {
565 awk -v unit="$1" '{printf "%s%s\n", unit, $0}'
566 }
567
568 status() {
569 local -r indent_unit=' '
570
571 uname -srvmo
572 hostname | figlet
573 uptime
574
575 echo
576
577 echo 'accounting'
578
579 printf '%stmux\n%ssessions %d, clients %d\n' \
580 "$indent_unit" \
581 "${indent_unit}${indent_unit}" \
582 "$(tmux list-sessions 2> /dev/null | wc -l)" \
583 "$(tmux list-clients 2> /dev/null | wc -l)"
584
585 echo
586
587 printf '%sprocs by user\n' "${indent_unit}"
588 ps -eo user \
589 | awk '
590 NR > 1 {
591 count_by_user[$1]++
592 total++
593 }
594
595 END {
596 for (user in count_by_user)
597 print count_by_user[user], total, user
598 }
599 ' \
600 | flat_top_5 \
601 | indent "${indent_unit}${indent_unit}"
602
603 echo
604
605 echo 'resources'
606 (
607 free | awk '$1 == "Mem:" {print $3, $2, "mem"}'
608 df ~ | awk 'NR == 2 {print $3, $3 + $4, "disk"}'
609 status_batt
610 ) \
611 | bar_gauge -v width=60 -v pct=1 \
612 | column -t \
613 | indent "$indent_unit"
614
615 echo
616
617 printf '%smem by proc\n' "$indent_unit"
618 ps -eo rss,comm \
619 | awk -v total="$(free | awk '$1 == "Mem:" {print $2; exit}')" '
620 NR > 1 {
621 rss = $1
622 proc = $2
623 by_proc[proc] += rss
624 }
625
626 END {
627 for (proc in by_proc)
628 print by_proc[proc], total, proc
629 }
630 ' \
631 | flat_top_5 \
632 | indent "${indent_unit}${indent_unit}"
633
634 echo
635
636 local _dir temp_input label_file label
637
638 printf '%sthermal\n' "$indent_unit"
639 for _dir in /sys/class/hwmon/hwmon*; do
640 cat "$_dir"/name
641 find "$_dir"/ -name 'temp*_input' \
642 | while read -r temp_input; do
643 label_file=${temp_input//_input/_label}
644 if [ -f "$label_file" ]; then
645 label=$(< "$label_file")
646 else
647 label=''
648 fi
649 awk -v label="$label" '{
650 if (label)
651 label = sprintf(" (%s)", label)
652 printf("%.2f°C%s\n", $1 / 1000, label)
653 }' \
654 "$temp_input"
655 done \
656 | sort \
657 | indent "$indent_unit"
658 done \
659 | indent "${indent_unit}${indent_unit}"
660
661 echo 'net'
662 #local -r internet_addr=$(internet_addr 0.5)
663 #local -r internet_ptr=$(host -W 1 "$internet_addr" | awk 'NR == 1 {print $NF}' )
664
665 #echo "${indent_unit}internet"
666 #echo "${indent_unit}${indent_unit}$internet_addr $internet_ptr"
667 echo "${indent_unit}if"
668 (ifconfig; iwconfig) 2> /dev/null \
669 | awk '
670 /^[^ ]/ {
671 device = $1
672 sub(":$", "", device)
673 if ($4 ~ "ESSID:") {
674 _essid = $4
675 sub("^ESSID:\"", "", _essid)
676 sub("\"$", "", _essid)
677 essid[device] = _essid
678 }
679 next
680 }
681
682 /^ / && $1 == "inet" {
683 address[device] = $2
684 next
685 }
686
687 /^ +Link Quality=[0-9]+\/[0-9]+ +Signal level=/ {
688 split($2, lq_parts_eq, "=")
689 split(lq_parts_eq[2], lq_parts_slash, "/")
690 cur = lq_parts_slash[1]
691 max = lq_parts_slash[2]
692 link[device] = cur / max * 100
693 next
694 }
695
696 END {
697 for (device in address)
698 if (device != "lo") {
699 l = link[device]
700 e = essid[device]
701 l = l ? sprintf("%.0f%%", l) : "--"
702 e = e ? e : "--"
703 print device, address[device], e, l
704 }
705 }
706 ' \
707 | column -t \
708 | indent "${indent_unit}${indent_unit}"
709
710 # WARN: ensure: $USER ALL=(ALL) NOPASSWD:/bin/netstat
711
712 echo "${indent_unit}-->"
713
714 sudo -n netstat -tulnp \
715 | awk -v indent="${indent_unit}${indent_unit}" '
716 NR > 2 && ((/^tcp/ && proc = $7) || (/^udp/ && proc = $6)) {
717 protocol = $1
718 addr = $4
719 port = a[split(addr, a, ":")]
720 name = p[split(proc, p, "/")]
721 names[name] = 1
722 protocols[protocol] = 1
723 if (!seen[protocol, name, port]++)
724 ports[protocol, name, ++seen[protocol, name]] = port
725 }
726
727 END {
728 for (protocol in protocols) {
729 printf "%s%s\t", indent, toupper(protocol)
730 for (name in names) {
731 if (n = seen[protocol, name]) {
732 sep = ""
733 printf "%s:", name
734 for (i = 1; i <= n; i++) {
735 printf "%s%d", sep, ports[protocol, name, i]
736 sep = ","
737 }
738 printf " "
739 }
740 }
741 printf "\n"
742 }
743 }'
744
745 echo "${indent_unit}<->"
746
747 printf '%sTCP\t' "${indent_unit}${indent_unit}"
748 sudo -n netstat -tnp \
749 | awk 'NR > 2 && $6 == "ESTABLISHED" {print $7}' \
750 | awk '{sub("^[0-9]+/", ""); print}' \
751 | sort -u \
752 | xargs \
753 | column -t
754
755 # TODO: iptables summary
756 }
757
758 ssh_invalid_by_addr() {
759 awk '
760 /: Invalid user/ && $5 ~ /^sshd/ {
761 addr=$10 == "port" ? $9 : $10
762 max++
763 by_addr[addr]++
764 }
765
766 END {
767 for (addr in by_addr)
768 if ((c = by_addr[addr]) > 1)
769 printf "%d %d %s\n", c, max, addr
770 }
771 ' \
772 /var/log/auth.log \
773 /var/log/auth.log.1 \
774 | sort -n -k 1 \
775 | bar_gauge -v width="$(stty size | awk '{print $2}')" -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
776 | column -t
777 }
778
779 ssh_invalid_by_day() {
780 awk '
781 BEGIN {
782 m["Jan"] = "01"
783 m["Feb"] = "02"
784 m["Mar"] = "03"
785 m["Apr"] = "04"
786 m["May"] = "05"
787 m["Jun"] = "06"
788 m["Jul"] = "07"
789 m["Aug"] = "08"
790 m["Sep"] = "09"
791 m["Oct"] = "10"
792 m["Nov"] = "11"
793 m["Dec"] = "12"
794 }
795
796 /: Invalid user/ && $5 ~ /^sshd/ {
797 day = m[$1] "-" $2
798 max++
799 by_day[day]++
800 }
801
802 END {
803 for (day in by_day)
804 if ((c = by_day[day]) > 1)
805 printf "%d %d %s\n", c, max, day
806 }
807 ' \
808 /var/log/auth.log \
809 /var/log/auth.log.1 \
810 | sort -k 3 \
811 | bar_gauge -v width="$(stty size | awk '{print $2}')" -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
812 | column -t
813 }
814
815 ssh_invalid_by_user() {
816 awk '
817 /: Invalid user/ && $5 ~ /^sshd/ {
818 user=$8
819 max++
820 by_user[user]++
821 }
822
823 END {
824 for (user in by_user)
825 if ((c = by_user[user]) > 1)
826 printf "%d %d %s\n", c, max, user
827 }
828 ' \
829 /var/log/auth.log \
830 /var/log/auth.log.1 \
831 | sort -n -k 1 \
832 | bar_gauge -v width="$(stty size | awk '{print $2}')" -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
833 | column -t
834 }
835
836 loggers() {
837 awk '
838 {
839 split($5, prog, "[")
840 sub(":$", "", prog[1]) # if there were no [], than : will is left behind
841 print prog[1]
842 }' /var/log/syslog /var/log/syslog.1 \
843 | awk '
844 {
845 n = split($1, path, "/") # prog may be in path form
846 prog = path[n]
847 total++
848 count[prog]++
849 }
850
851 END {
852 for (prog in count)
853 print count[prog], total, prog
854 }' \
855 | sort -n -k 1 \
856 | bar_gauge -v num=1 -v ch_right=' ' -v ch_left=' ' -v ch_blank=' ' \
857 | column -t
858 }
This page took 0.153271 seconds and 4 git commands to generate.