Skip to content

Instantly share code, notes, and snippets.

@pirafrank
Created July 10, 2016 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirafrank/39f231552706f1c843a21df723d23c28 to your computer and use it in GitHub Desktop.
Save pirafrank/39f231552706f1c843a21df723d23c28 to your computer and use it in GitHub Desktop.
Script to 'jekyllfy' url images. Replaces your website url with {{site.baseurl}}. Useful when you want to preview your images in editor (iA Writer?) before committing markdown files to repo. sed command is compatible with OS X version of sed.
#!/bin/bash
if [[ $# != 1 ]]; then
echo "Error: you need to pass the path where markdown file are!"
echo "Usage: ./jekyllfy_image_urls.sh [path]"
exit 1
fi
# changing urls... (this edit in place creating NO backup files!)
find "$1" -name "*.md" -exec sed -i '' 's#http://your.website.com#{{site.baseurl}}#g' {} \;
# if you want backup files, use the version below
#find "$1" -name "*.md" -exec sed -i.bkp 's#http://your.website.com#{{site.baseurl}}#g' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment