cfg/bin/color_from_hostname.py

13 lines
198 B
Python
Raw Normal View History

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