X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Flib%2Flogin_functions.sh;h=cae7b990afcd3791903426b51e8d65b1cd4acb6b;hb=713423d0746543e393a72bfe1a600d024d064485;hp=944257970c1d4a2f4bbbd5b5c6675b52e0d1f847;hpb=b8651fc6c6717ce4d18574e147f291df1eb8c831;p=khome.git diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 9442579..cae7b99 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -140,16 +140,29 @@ top_commands() { # TODO: Consider using numfmt instead of awk tdu() { du "$1" \ - | sort -n -k 1 \ - | tail -50 \ | awk ' { size = $1 path = $0 sub("^" $1 "\t+", "", path) - gb = size / 1024 / 1024 - printf("%f\t%s\n", gb, path) - }' + paths[path] = size + if (size > max) + max = size + } + + END { + for (path in paths) { + size = paths[path] + pct = 100 * (size / max) + gb = size / 1024 / 1024 + printf("%6.2f %3d%% %s\n", gb, pct, path) + } + } + ' \ + | sort -r -n -k 1 \ + | head -50 \ + | tac + # A slight optimization: head can exit before traversing the full input. } # Top Disk-Using Files @@ -224,8 +237,9 @@ man() { command man "$@" } -experiment() { - cd "$(~/bin/experiment $@)" || kill -INT $$ +# new experiment +x() { + cd "$(~/bin/x $@)" || kill -INT $$ } hump() { @@ -262,7 +276,10 @@ yt_video() { } gh_fetch_repos() { - curl "https://api.github.com/$1/$2/repos?page=1&per_page=10000" + local -r user_type="$1" + local -r user_name="$2" + + curl "https://api.github.com/$user_type/$user_name/repos?page=1&per_page=10000" } gh_clone() { @@ -539,12 +556,22 @@ status() { echo - local -r internet_addr=$(internet_addr 0.5) - local -r internet_ptr=$(host -W 1 "$internet_addr" | awk 'NR == 1 {print $NF}' ) + printf '%sthermal\n' "$indent_unit" + for _dir in /sys/class/thermal/thermal_zone* + do + printf '%s %.2f C\n' \ + $(cat "$_dir"/type) \ + $(( $(cat "$_dir"/temp) / 1000 )) + done \ + | column -t \ + | indent "${indent_unit}${indent_unit}" echo 'net' - echo "${indent_unit}internet" - echo "${indent_unit}${indent_unit}$internet_addr $internet_ptr" + #local -r internet_addr=$(internet_addr 0.5) + #local -r internet_ptr=$(host -W 1 "$internet_addr" | awk 'NR == 1 {print $NF}' ) + + #echo "${indent_unit}internet" + #echo "${indent_unit}${indent_unit}$internet_addr $internet_ptr" echo "${indent_unit}if" (ifconfig; iwconfig) 2> /dev/null \ | awk '