Minimal Hostname Naming
Naming things is hard and the temptation to come up with the Right Naming Convention™ can become a mental block for a certain type of person 👀
Currently, I use this function in my ~/.bashrc:
genhostname() {
echo "${1:-localhost}-$(gentag 4)"
}
gentag() {
# This is in its own function since it's useful for other stuff too
head -c 512 /dev/urandom | md5sum | head -c${1:-'6'}
}Which can be used like this:
$ genhostname media-mgmt
media-mgmt-c95c
$ genhostname web-proxy
web-proxy-88de
# And here's gentag
$ gentag
ac5d92
$ gentag 12
c2ff66ef39cf