dynamically generate hostname color

This commit is contained in:
Knut Ahlers 2016-08-01 17:24:20 +02:00
parent e424459826
commit 1c064f3e82
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 13 additions and 1 deletions

View file

@ -17,7 +17,7 @@ function prompt_char {
} }
function box_color { function box_color {
[ -f ~/.box_color ] && cat ~/.box_color || echo '$FG[033]' [ -f ~/.box_color ] && cat ~/.box_color || ~/bin/color_from_hostname.py
} }
function box_name { function box_name {

12
bin/color_from_hostname.py Executable file
View file

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