Skip to content

Instantly share code, notes, and snippets.

@q0rban
Created November 16, 2012 16:03
Show Gist options
  • Save q0rban/4088499 to your computer and use it in GitHub Desktop.
Save q0rban/4088499 to your computer and use it in GitHub Desktop.
Monosnap/Github Shell Script
#!/usr/bin/env sh
# https://gist.github.com/4088499
FIND="^monosnap.com\/image\/\([a-zA-Z0-9]*\)"
REPLACE="![](https:\/\/api.monosnap.com\/image\/download\?id=\1)"
pbpaste |
# Different versions of monosnap have this formatted differently, so we grep
# first for just what we need.
grep -o monosnap.com/image/[a-zA-Z0-9]* |
# Grab the current cliboard contents and do our replacement.
sed -n "s/$FIND/$REPLACE/p" |
# Trim off any trailing new lines that sed might add.
tr -d '\n' |
# Put it back in the clipboard.
pbcopy
@q0rban
Copy link
Author

q0rban commented Nov 16, 2012

Here's how I have it set up in Alfred:

@webthingee
Copy link

Changed Replace for direct GITHUB link:
REPLACE="img"

@webthingee
Copy link

REPLACE="![img](https:\/\/api.monosnap.com\/image\/download\?id=\1)"

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