Last active
May 30, 2024 23:27
-
-
Save dereckmezquita/a84057c95f7a8f994823b51fce377a16 to your computer and use it in GitHub Desktop.
Messages of the day for Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# /etc/update-motd.d/99-disk-usage.sh | |
# Define colors for pretty output | |
YELLOW="\e[33m" | |
RESET="\e[0m" | |
# Get the disk usage information with header | |
DISK_USAGE_HEADER=$(df -h --output=source,fstype,size,used,avail,pcent,target | head -n 1) | |
DISK_USAGE=$(df -h --output=source,fstype,size,used,avail,pcent,target | grep -E '^/dev' | grep -E '/$|/mnt|/media|/data|/nvme0|/nvme1') | |
# Create the MOTD content | |
MOTD_CONTENT="${YELLOW}Disk Usage Information:${RESET} | |
${DISK_USAGE_HEADER} | |
${DISK_USAGE} | |
${RESET}" | |
# Print the MOTD content | |
echo -e "$MOTD_CONTENT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment