Created
January 4, 2019 14:32
-
-
Save dgomes/b89b3a7f3b6bdfac28fe6b5e1d3b7920 to your computer and use it in GitHub Desktop.
Open OSX .webloc files in Linux
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
#!/usr/bin/env bash | |
# Based on https://blog.scottlowe.org/2016/12/21/opening-webloc-files-ubuntu/ | |
if ! [ $(command -v xmllint) ]; then | |
echo "xmllint not installed" | |
exit | |
fi | |
if ! [ $(command -v plistutil) ]; then | |
echo "plistutil not installed" | |
exit | |
fi | |
# Test to be sure user supplied a parameter; error if not | |
if [ $# -eq 0 ]; then | |
echo "Please supply the name of a .webloc file to open" | |
exit | |
fi | |
# Extract URL from webloc file | |
URL=$(plistutil -i "$1" | xmllint --xpath "string(//string)" -) | |
# Open $URL in browser | |
xdg-open $URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment