Closed raymod2 closed 6 years ago
It is unfortunate that Microsoft do not want to enable this by default, because such behavior break lots of receipts (
@mrbianchi Thanks you for your script !! ;)
Unfortunately it does not work for custom built binaries like custom python:
./python --verison
-bash: ./python: Is a directory
For zsh just put this code into ~/.zshrc
command_not_found_handler() { if cmd.exe /c "(where $1 || (help $1 |findstr /V Try)) >nul 2>nul && ($* || exit 0)"; then return $? else [[ -x /usr/lib/command-not-found ]] || return 1 /usr/lib/command-not-found --no-failure-msg -- ${1+"$1"} && : fi }
@aaronsvk May I use your scripts for zshrc and bashrc in a project I am working on? I will be attempting to make a script/installer that will preconfigure WSL2 and Windows Terminal to more sane defaults so that everything feels better integrated and w/ similar keymaps as macOS has for their own Terminal. (copy, paste, no collisions with Linux based apps or terminal)
Also I really do appreciate those scripts, that is exactly what I was needing.
The problem with command_not_found_handle
is that although this handler is fired when used manually, but when I run some script like ./run.sh
and this file has some usage of .exe
without actual extension inside, it still says command not found
. Even though it works when I run those commands manually
In a Windows command shell I can type "notepad.exe" or "notepad" and in both cases it will launch the same executable binary. In Bash on Windows I must use "notepad.exe". Is it feasible to get "notepad" working on Bash? If "notepad" is not found in the path then search for "notepad.exe", "notepad.com", etc., just like the Windows command shell.