Skip to content

Instantly share code, notes, and snippets.

@liukun
liukun / getgist
Last active August 29, 2015 14:00 — forked from bmihaylov/getgist
#!/usr/bin/env bash
if [[ "$1" =~ ^[0-9]+ ]]; then
curl -L "http://gist.github.com/$1/download" | tar zx --strip-components 1
exit 0
fi
curl -L "$1/download" | tar zx --strip-components 1
local char_to_hex = function(c)
return string.format("%%%02X", string.byte(c))
end
local function urlencode(url)
if url == nil then
return
end
url = url:gsub("\n", "\r\n")
url = url:gsub("([^%w ])", char_to_hex)