Skip to content

Commit

Permalink
Merge branch 'fix/SunOS-hostname-hash' (GH #461, #462)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolmen committed Sep 29, 2016
2 parents 18fd3fb + 01b3ffa commit 9c1c8a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Expand Up @@ -5,7 +5,9 @@ NEXT
we now unexport it on startup
Bug fixes:
- Fix regression in LP_ENABLE_FQDN implementation (GitHub #472)
Thanks to Roman (@hatifnatt), Jon Garrison (@jpwgarrison)...
- Fix LP_COLOR_HOST_HASH on SunOS (GitHub #461, #462)
Thanks to Roman (@hatifnatt), Jon Garrison (@jpwgarrison),
Mark Vander Stel (@Rycieos)...
... for their patches or bug reports.

1.11 2016-06-25
Expand Down
7 changes: 4 additions & 3 deletions liquidprompt
Expand Up @@ -288,9 +288,10 @@ _lp_source_config()

# compute the hash of the hostname
# and get the corresponding number in [1-6] (red,green,yellow,blue,purple or cyan)
# FIXME check portability of cksum and add more formats (bold? 256 colors?)
local hash=$(( 1 + $(hostname | cksum | cut -d " " -f 1) % 6 ))
LP_COLOR_HOST_HASH="${_LP_OPEN_ESC}$(ti_setaf $hash)${_LP_CLOSE_ESC}"
# FIXME Add more formats (bold? 256 colors?)
# cksum is separated with tab on SunOS, space on others
local cksum="$(hostname | cksum)"
LP_COLOR_HOST_HASH="${_LP_OPEN_ESC}$(ti_setaf $(( 1 + ${cksum%%[ ]*} % 6 )) )${_LP_CLOSE_ESC}"

unset ti_sgr0 ti_bold
unset -f ti_setaf ti_setab
Expand Down

0 comments on commit 9c1c8a3

Please sign in to comment.