Display array status in prompt

If you’re using md RAID and want your array status displayed in your prompt, create a file in /etc/profile.d/
called raid_status.sh with the following function definition:
raid_prompt() { awk '/^md/ {printf "%s: ", $1}; /blocks/ {print $NF}' /proc/mdstat | awk '/\[U+\]/ {print "\033[32m" $0 "\033[0m"}; /\[.*_.*\]/ {print "\033[31m" $0 "\033[0m"}'; }

Then add $(raid_prompt) to your PS1 environment variable to include the array name and member status in green if all members are up, or red if any member has failed:
export PS1='$(raid_prompt)\n[\u@\h \W]\$ '

(Remember to use single quotes, or the value will remain static, instead of getting updated every time the prompt is displayed.)

Hi,

Can you edit and post your code with proper formatting?

Ha! Oops! Didn’t realize that’s what those buttons were for.