Skip to content

Instantly share code, notes, and snippets.

@cmcculloh
Last active November 8, 2017 06:34
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 cmcculloh/11432852 to your computer and use it in GitHub Desktop.
Save cmcculloh/11432852 to your computer and use it in GitHub Desktop.
Takes contents of clipboard, syntax highlights them, pasts them into a gist, opens the gist in a browser, and puts syntax highlighted version of text in clipboard for pasting into Evernote/email/etc
#!/bin/bash
# Takes contents of clipboard, syntax highlights them, places a copy in "gists" directory in Google Drive, pastes them into a gist, opens the gist in a browser, and puts syntax highlighted version of text in clipboard for pasting into Evernote/email/etc
# requires:
#* gist (https://github.com/defunkt/gist)
#* Google Drive
#* highlight (brew install highlight)
#* an alias that will run this file `alias gst="~/gst.sh"`
# Call like:
# gst gistname.ext "gist description"
echo "creating $1 at:"
gist -P -o -f $1 -d "$2"
touch "/Users/cmcculloh/Google Drive/gists/$1"
pbpaste > "/Users/cmcculloh/Google Drive/gists/$1"
extension="${1##*.}"
highlight -O rtf -t 2 -K 11 -k 'Source Code Pro' --syntax $extension "/Users/cmcculloh/Google Drive/gists/$1" | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment