Skip to content

Instantly share code, notes, and snippets.

@dereckmezquita
Last active May 30, 2024 23:27
Show Gist options
  • Save dereckmezquita/a84057c95f7a8f994823b51fce377a16 to your computer and use it in GitHub Desktop.
Save dereckmezquita/a84057c95f7a8f994823b51fce377a16 to your computer and use it in GitHub Desktop.
Messages of the day for Linux
#!/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