Sharing scripts – an easier way

Still new to this blogging thing and so far all my posts have been about PowerCLI. I use Github to store my scripts after I sanitize them for public consumption – its a great tool for storing your scripts, versioning and getting input from others. One thing that bugged me between Github and Blog, though, was needing to copy and paste my code into the blog posts every time I wrote or updated them. The only way I could find the share the code and keep it up to date on Github was to start a Gist. This still meant keeping a copy in two places, until I stumbled upon this cool feature.

For this blog I use WordPress with a number of modules, to me it doesn’t feel as comfortable or flexible as Joomla, which I’ve built other sites with, but from a coders perspective, Joomla lacked the ability to properly mark-up my scripts. When looking for a module to do scripting markup I played with several, but found Crayon Syntax Highlighter best suited my needs. It had Powershell native highlighting, some tech-looking templates, and just too many features to list here.

For my first two posts, I was happy to copy and paste code from Github to Crayon, then I updated and did it again and then I found a line in the Crayon editor that made my life easier. A URL line, so I tried it, but going native to Github brought in all the html formatting in the background. Went over to Git hub, and saw I could view my scripts in raw format, and there it was…no more copy and paste! The script looks exactly as it would when I copy-pasted but now I can keep scripts up-to-date without that extra step. Simply place my code on Github, hit the “RAW” button to see the code in “naked” text and copy that URL into Crayon for syntax highlighting.

Crayon add code dialog show where I was pasting code, and where the “raw” URL can go.
Github code screen and where to find the “raw” display
Github “raw” display and URL

I’m likely not the first to find this, but in case this article helps other, here it is. The nice thing is I just need to update code in Github. Of course now I’ve got to keep my Annotations up-to-date, maybe I’ll get away from using line numbers and rather use commented sections, but that’s another story for another day.