Skip to content

Instantly share code, notes, and snippets.

@naryal2580
Created August 26, 2020 11:08
Show Gist options
  • Save naryal2580/550ce1e279d961d81476e335c3a4df49 to your computer and use it in GitHub Desktop.
Save naryal2580/550ce1e279d961d81476e335c3a4df49 to your computer and use it in GitHub Desktop.
Either source this on .bashrc or copy and paste it to your .bashrc of WSL you are working on, and forget appending .exe on commands like powershell and cmd
trap 'BASH_CMD=$BASH_COMMAND' DEBUG
command_not_found_handle () {
only_cmd=${BASH_CMD%% *}
if type "$only_cmd.exe"
then
only_args=${BASH_CMD#* }
cmd="$only_cmd.exe $only_args"
$cmd
else
echo "-bash: $only_cmd: Command not found"
return 127
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment