Created
December 19, 2018 23:02
-
-
Save smuuf/d1aba3088b174e23b0cde03d4f3213c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Sets the color of next text output to be a random color based on hostname's md5 hash. | |
# (If the terminal supports true colour (RGB) colors.) | |
set_host_based_color() { | |
HOSTHASH=$(hostname | md5sum) | |
printf "\x1b[38;2;%d;%d;%dm" 0x${HOSTHASH:0:2} 0x${HOSTHASH:2:2} 0x${HOSTHASH:4:2} | |
} | |
# Example usage: | |
# PS1="[\$(set_host_based_color)\$(hostname)\033[0m]: " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment