dynamically generate hostname color
This commit is contained in:
parent
e424459826
commit
1c064f3e82
2 changed files with 13 additions and 1 deletions
|
@ -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
12
bin/color_from_hostname.py
Executable 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)
|
Loading…
Reference in a new issue