Created
July 18, 2022 20:38
-
-
Save gregory-seidman/65e8e585dd2b0c8433a4e9b4c6484184 to your computer and use it in GitHub Desktop.
A hacky xdg-open drop-in replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Download this, name it xdg-open, and move it to somewhere early in your | |
# path on your WSL2 Linux filesystem | |
usage () { | |
echo "Usage: $0 <file URL>" >&2 | |
exit 1 | |
} | |
test $# -ne 1 && usage | |
case "$1" in | |
-h|--help|--manual|--version) | |
echo "This is a hacky xdg-open replacement for WSL2" >&2 | |
usage | |
;; | |
-*) echo "Unknown option" | |
esac | |
if printf '%s\n' "$1" | grep '^[a-zA-Z]\+://' >/dev/null | |
then | |
/mnt/c/Windows/system32/cmd.exe /c start "$1" | |
else | |
/mnt/c/Windows/system32/cmd.exe /c start "$(wslpath -w "$1")" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment