A tool for opening URL's using their OS defined default application. This is an abstraction around standard OS specific default program opening commands:
- Linux:
xdg-open <URL>- WSL: uses
wslpathto convert to windows path then uses the Windows opener
- WSL: uses
- Mac:
open <URL> - Windows:
powershell.exe -c "Start-Process -FilePath <URL>"
After installation, you can simply open urls:
# open a web browser at a specific url
open https://github.com/pastdev/open
# open an image viewer
open ~/pictures/me.jpg
# open a text editor
open /tmp/app.outopen is a self contained binary that has pre-built releases for various platforms.
You may find this script valuable for installation:
# note this command uses clconf which can be found here:
# https://github.com/pastdev/clconf
(
# where do you want this installed?
binary="${HOME}/.local/bin/open"
# one of linux, darwin, windows
platform="linux"
curl \
--location \
--output "${binary}" \
"$(
curl --silent https://api.github.com/repos/pastdev/open/releases/latest \
| clconf \
--pipe \
jsonpath "$..assets[*][?(@.name =~ /askai-${platform/windows/windows.exe}/)].browser_download_url" \
--first)"
chmod 0755 "${binary}"
)Use the default go run:
go run ./cmd/open "https://github.com/pastdev/open"