From 6b09a6b1989162fd556483831ebdee63c75d9296 Mon Sep 17 00:00:00 2001 From: Jose Gracia Date: Mon, 15 Jul 2024 11:54:39 +0200 Subject: [PATCH] Add env for ws_quickcheck --- envs/ws_quickcheck/README.md | 3 ++ envs/ws_quickcheck/ws_quickcheck.env | 47 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 envs/ws_quickcheck/README.md create mode 100644 envs/ws_quickcheck/ws_quickcheck.env diff --git a/envs/ws_quickcheck/README.md b/envs/ws_quickcheck/README.md new file mode 100644 index 0000000..311d56d --- /dev/null +++ b/envs/ws_quickcheck/README.md @@ -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. diff --git a/envs/ws_quickcheck/ws_quickcheck.env b/envs/ws_quickcheck/ws_quickcheck.env new file mode 100644 index 0000000..af98b37 --- /dev/null +++ b/envs/ws_quickcheck/ws_quickcheck.env @@ -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