-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(open-url): add support for opening a url across platforms
- Loading branch information
Deavon M. McCaffery
committed
Dec 28, 2016
1 parent
d142880
commit 8509caa
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
open-url() { | ||
local url="$1" | ||
|
||
if [ -z "${1:-}" ]; then | ||
echo "open-url: url must be supplied" | ||
return 1 | ||
fi | ||
|
||
for cmd in open gnome-open kde-open xdg-open sensible-browser; do | ||
if type "$cmd" 1>/dev/null 2>&1; then | ||
echo "opening $url via $cmd..." | ||
"$cmd" "$url" | ||
return 0 | ||
fi | ||
done | ||
|
||
return 1 | ||
} |
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