cfg/bin/color_from_hostname.py
Knut Ahlers 04a54c4a48
Use only first part of hostname
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-07-20 08:56:55 +02:00

13 lines
198 B
Python
Executable File

#!/usr/bin/env python
import socket
hostname = socket.gethostname().split('.')[0]
s = 0
for c in hostname:
s = s + ord(c)
color = str(1 + s % 14).rjust(3, '0')
print '$FG[{}]'.format(color)