Skip to content

Instantly share code, notes, and snippets.

@echohn
Last active December 26, 2017 09:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echohn/eb8f31165aa288a3d0de115ac11ee543 to your computer and use it in GitHub Desktop.
Save echohn/eb8f31165aa288a3d0de115ac11ee543 to your computer and use it in GitHub Desktop.
safari auto backup bookmarks bash script
#!/bin/bash
usage(){
echo "USAGE: bash $0 OUTPUT_PATH"
exit 1
}
[[ $# -ne 1 ]] && usage
backup_path=$1
this_dir=$(cd "$(dirname "$0")"; pwd)
today=$(date +%Y-%m-%d)
temp_file="/tmp/${today}-bookmarks.xml"
plutil -convert xml1 -o $temp_file ~/Library/Safari/Bookmarks.plist
xsltproc $this_dir/Bookmarks.xslt $temp_file | sed 's/<\/DT>//g' > $backup_path/$today-bookmarks.html
rm -f $temp_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment