diff --git a/.Jules/palette.md b/.Jules/palette.md index 25d68a2..fda0ca8 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -1,3 +1,7 @@ ## 2025-12-14 - [Bash Script UX] **Learning:** CLI tools in this repo are heavily macOS-dependent but lack compatibility checks, leading to confusing errors on other systems. **Action:** When working on shell scripts, always add `command -v` checks or OS detection to provide clear feedback instead of raw errors. + +## 2025-12-15 - [CLI Header Retention] +**Learning:** Standard `sort` commands in pipelines often swallow or displace CSV/Table headers, making output unreadable. +**Action:** Use `awk 'NR==1 {print; next} {print | "sort ..."}'` pattern to reliably preserve headers in sorted CLI output. diff --git a/ops/monitoring/top-hogs.sh b/ops/monitoring/top-hogs.sh index 931acf0..d1aa8b5 100755 --- a/ops/monitoring/top-hogs.sh +++ b/ops/monitoring/top-hogs.sh @@ -4,8 +4,13 @@ set -e -echo "[top-hogs] Top 10 CPU-consuming processes:" -ps aux | sort -nrk 3 | head -n 11 +# ANSI Color Codes +BLUE='\033[0;34m' +BOLD='\033[1m' +RESET='\033[0m' -echo "\n[top-hogs] Top 10 Memory-consuming processes:" -ps aux | sort -nrk 4 | head -n 11 \ No newline at end of file +echo -e "${BLUE}${BOLD}[top-hogs] Top 10 CPU-consuming processes:${RESET}" +ps aux | awk 'NR==1 {print; next} {print | "sort -nrk 3 | head -n 10"}' + +echo -e "\n${BLUE}${BOLD}[top-hogs] Top 10 Memory-consuming processes:${RESET}" +ps aux | awk 'NR==1 {print; next} {print | "sort -nrk 4 | head -n 10"}'