When opening a URI from a Mac terminal in a default browser, you can use the open command to:
$open http://example.com/
However, you cannot do the same with URIs that begin with data: .
I think I'm looking for it locally as a file.
$open data:text/plain; base64,SGVsbG8sIFdvcmxkIQ==
The file/Users/yuya/src/github.com/yuya-takeyama/qrcat/data:text/plain does not exist.
zsh:command not found:base64,SGVsbG8sIFdvcmxkIQ==
Is there any way to do this well?
I would like to open it in the default browser without specifying a specific browser.
I found a similar question in the English version of SO.
osx-Open an.html file with default browser using Bash on Mac
This section describes how to use the third-party command DefaultApplication.If you use this, you can write like this (although I don't have a Mac on hand, so I can't verify it).
open-a"$(/usr/local/bin/DefaultApplication-url'http:')""data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="
There seems to be a way to get the default browser using Perl or AppleScript.
osx-Discover default browser programmatically on Mac-Super User
© 2024 OneMinuteCode. All rights reserved.