Skip to content

Instantly share code, notes, and snippets.

@rodrigobdz
Created January 27, 2018 14:52
Show Gist options
  • Save rodrigobdz/c68be1310eb84dab8569f19bc75c572b to your computer and use it in GitHub Desktop.
Save rodrigobdz/c68be1310eb84dab8569f19bc75c572b to your computer and use it in GitHub Desktop.
Edit .svg files in macOS and livereload
#!/bin/bash
FILE_TO_WATCH=<PATH TO SVG>
filewatcher $FILE_TO_WATCH 'reload' "osascript -e 'tell application \"Safari\" to set URL of current tab of front window to \"file://$FILE_TO_WATCH\"'"
@rodrigobdz
Copy link
Author

rodrigobdz commented Jan 27, 2018

Watch and Reload

Script to edit an SVG file in a text editor and preview and reload the changes on save in Safari.

Requirements

  • Set the variable FILE_TO_WATCH to the absolute path to your SVG file in watch-and-reload.sh.

Usage

  1. Run script.
# Make script executable
$ chmod +x watch-and-reload.sh
# Run script
$ ./watch-and-reload.sh
  1. Open the SVG file you selected for the watch-and-reload.sh script in a text editor.
  2. Make some changes in the file and save it.
  3. Safari should open and show a preview of your SVG. Changes you make are reflected automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment