Add env for ws_quickcheck

This commit is contained in:
Jose Gracia 2024-07-15 11:54:39 +02:00
parent ac63b1eec1
commit 6b09a6b198
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# ws_quickcheck
Add the contents of the file `ws_quickcheck.env` to your `.basrc` (or similar) to get a short summary of the status of your workspaces at shell startup.

View file

@ -0,0 +1,47 @@
# This file is meant to be sourced, not executed.
# Add the contents to your shell startup file, i.g. `.bashrc`
# Summary of workspace status
function ws_quickcheck() {
ws_list -R | awk -e '
BEGIN {
color_red="\033[31m"
color_green="\033[32m"
color_orange="\033[33m"
color_blue="\033[34m"
color_clear="\033[0m"
num_ws=0
print color_blue "--------------------------------------------------------
------------" color_clear;
print color_blue "Workspaces:" color_clear;
print color_blue "--------------------------------------------------------
------------" color_clear;
}
/^id:/ {
ws_name=$2;
}
/remaining time/ {
gsub("^.*:","",$0);
days=$1;
hours=$3
color=color_green;
remaining=days + hours / 24;
if (remaining < 7)
color=color_red;
else if(remaining < 14)
color=color_orange;
printf color "%-60s %7.2f" color_clear "\n", ws_name, remaining;
num_ws = num_ws + 1
}
END {
if (num_ws < 1)
print color_blue "(no workspaces)"
print color_blue "--------------------------------------------------------------------" color_clear;
}
'
}
# check if interactive shell
if [ -t 1 ]; then
ws_quickcheck
fi