X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Flib%2Flogin_functions.sh;h=01e0ffa63d71c1de5b0de37c1b813c8b1e899be3;hb=773a0061dccdd6763fbff37335038aa636960add;hp=15f6e3c412f9bccf82ef273bf71b8f35c93aca67;hpb=1be8e74bb12167f8e6adf899612b20cfb16a9ce5;p=khome.git diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 15f6e3c..01e0ffa 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 @@ -263,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() { @@ -318,7 +334,7 @@ EOF work_log() { mkdir -p "$DIR_WORK_LOG" - local -r file_work_log_today="${DIR_WORK_LOG}/$(date +%F).md" + local -r file_work_log_today="${DIR_WORK_LOG}/daily-$(date +%F).md" if [ ! -f "$file_work_log_today" ] then work_log_template > "$file_work_log_today" @@ -551,11 +567,11 @@ status() { | indent "${indent_unit}${indent_unit}" echo 'net' - local -r internet_addr=$(internet_addr 0.5) - local -r internet_ptr=$(host -W 1 "$internet_addr" | awk 'NR == 1 {print $NF}' ) + #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}internet" + #echo "${indent_unit}${indent_unit}$internet_addr $internet_ptr" echo "${indent_unit}if" (ifconfig; iwconfig) 2> /dev/null \ | awk '