Skip to content

Instantly share code, notes, and snippets.

@DzeryCZ
Created April 13, 2018 21:17
Show Gist options
  • Save DzeryCZ/aa0063c3143c2f69d7469285bbd0567f to your computer and use it in GitHub Desktop.
Save DzeryCZ/aa0063c3143c2f69d7469285bbd0567f to your computer and use it in GitHub Desktop.
Run Windows Programs (.exe) from WSL as Fallback without extension
# Add at the end of your ~/.bashrc file this content:
# Run Windows Programs (.exe) from WSL as Fallback without extension
eval "$(echo "orig_command_not_found_handle()"; declare -f command_not_found_handle | tail -n +2)"
command_not_found_handle()
{
cmd=$1
shift
args=( "$@" )
IFS=:
for dir in $PATH; do
for executable in $dir/$cmd.exe $dir/$cmd.com $dir/$cmd.bat; do
if [ -x $executable ]; then
"$executable" "${args[@]}"
return
fi
done
done
orig_command_not_found_handle "$cmd" "${args[@]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment