2# This script creates an Alfred snippet bundle that expands my HTML template
3# when I type the shortcut `!html`.
10ROOT=$(git rev-parse --show-toplevel
)
14 # 1. Create the `info.plist` files with the settings for this collection
15 # of snippets: no keyword prefix/suffix.
16 cat > info.plist
<<EOF
17<?xml version="1.0" encoding="UTF-8"?>
18<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
21 <key>snippetkeywordprefix</key>
23 <key>snippetkeywordsuffix</key>
29 # Get the HTML template as a JSON-escaped string
30 snippet=$(jq -R -s
'.' <
"$ROOT/TEMPLATE.html")
32 # This is an arbitrary choice of ID; it just has to be used consistently
33 snippet_id="$(uuidgen
)"
35 # 2. Create the snippet JSON file, which expands the HTML when I type the
37 cat >
"$snippet_id.json" <<EOF
42 "name": "HTML template",
48 # 3. Bundle the info.plist and snippet JSON into an `alfredsnippets`
49 # package, and open it in Alfred.
50 zip
"HTML template.alfredsnippets" "info.plist" "$snippet_id.json"
51 open
"HTML template.alfredsnippets"