From 06c6a3d0adedc85cb14bd07e1d0d89ca192fcfd3 Mon Sep 17 00:00:00 2001 From: Rinyre Date: Sat, 13 May 2017 13:40:00 -0500 Subject: [PATCH] Added support for Bash on Windows --- .../command-not-found.plugin.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh index 0e2f2133..029f9b6b 100644 --- a/plugins/command-not-found/command-not-found.plugin.zsh +++ b/plugins/command-not-found/command-not-found.plugin.zsh @@ -31,3 +31,22 @@ if type brew &> /dev/null; then eval "$(brew command-not-found-init)"; fi fi + +# Bash on Windows support +# https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364 +SYS_KERNEL=`cat /proc/sys/kernel/osrelease` +case "$SYS_KERNEL" in + *WSL*|*Microsoft*) command_not_found_handler () { + commandsent="$@" + buffer=("${(@s/ /)commandsent}") + which $buffer[1].exe>/dev/null + if [ $? -eq 0 ]; then + buffer[1]=$buffer[1].exe + $buffer + return 0 + else + return 1 + fi + } ;; + *) ;; +esac