mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
disco prompt: Pad hash
It's possible cksum returns less than 3 full bytes, so let's just turn the ones we don't get into 0 Fixes #9164
This commit is contained in:
parent
227e1f6300
commit
07b2f1054b
1 changed files with 1 additions and 1 deletions
|
@ -19,7 +19,7 @@ function fish_prompt
|
|||
# We hash the physical PWD and turn that into a color. That means directories (usually) get different colors,
|
||||
# but every directory always gets the same color. It's deterministic.
|
||||
# We use cksum because 1. it's fast, 2. it's in POSIX, so it should be available everywhere.
|
||||
set -l shas (pwd -P | cksum | string split -f1 ' ' | math --base=hex | string sub -s 3 | string match -ra ..)
|
||||
set -l shas (pwd -P | cksum | string split -f1 ' ' | math --base=hex | string sub -s 3 | string pad -c 0 -w 6 | string match -ra ..)
|
||||
set -l col 0x$shas[1..3]
|
||||
|
||||
# If the (simplified idea of) luminance is below 120 (out of 255), add some more.
|
||||
|
|
Loading…
Reference in a new issue