Skip to content

Instantly share code, notes, and snippets.

@dgomes
Created January 4, 2019 14:32
Show Gist options
  • Save dgomes/b89b3a7f3b6bdfac28fe6b5e1d3b7920 to your computer and use it in GitHub Desktop.
Save dgomes/b89b3a7f3b6bdfac28fe6b5e1d3b7920 to your computer and use it in GitHub Desktop.
Open OSX .webloc files in Linux
#!/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