summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-02-24 17:48:18 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2019-02-24 17:48:18 +0000
commit03857d98c4170ce2da05b1abc1b706d34f16203c (patch)
tree648b33fc8aa7ae90872135ed1fbdd7e1d97a6b11
parentf612b06043d6fd9b9beedcab11f92a90f9e9910b (diff)
zsh/functions: don't use hostcolor on WSL
On Windows Subsystem for Linux 1809, zsh hangs if given a pipe inside a command substitution. In the palette code, it's not possible to avoid these, since we want to hash the hostname without a trailing newline, and here-strings automatically include a trailing newline. If /proc/version exists and it looks like it's from a WSL instance, set the host color to white instead. Additionally, port over some of the code for working systems to use here-strings, since they are more compact and easier to read. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--zsh/functions/bmc_palette17
1 files changed, 11 insertions, 6 deletions
diff --git a/zsh/functions/bmc_palette b/zsh/functions/bmc_palette
index 6014794..ee9152e 100644
--- a/zsh/functions/bmc_palette
+++ b/zsh/functions/bmc_palette
@@ -50,12 +50,17 @@ bmc_palette () {
# the hostname is broken, it will take forever to render our prompt.
if [[ $color = hostcolor ]]
then
- local hostname=$( (hostname -f 2>/dev/null || hostname 2>/dev/null || printf localhost) | tr -d '\n')
- local hostcolor="$(printf '%s' "$hostname" | bmc_palette_sha256)"
- colors[hostcolor]="no
- 0x$(echo $hostcolor | cut -b1-6)
- 0x$(echo $hostcolor | cut -b1-2)
- white"
+ if grep -qs Microsoft /proc/version 2>/dev/null
+ then
+ colors[hostcolor]="no 0xffffff 15 white"
+ else
+ local hostname=$( (hostname -f 2>/dev/null || hostname 2>/dev/null || printf localhost) | tr -d '\n')
+ local hostcolor="$(printf '%s' "$hostname" | bmc_palette_sha256)"
+ colors[hostcolor]="no
+ 0x$(cut -b1-6 <<<"$hostcolor")
+ 0x$(cut -b1-2 <<<"$hostcolor")
+ white"
+ fi
fi
local expanded="$colors[$color]"