Skip to content

Instantly share code, notes, and snippets.

@xbalaji
Last active October 10, 2022 04:05
Show Gist options
  • Save xbalaji/aad039751ec43e7eb1052d6aabcdaa82 to your computer and use it in GitHub Desktop.
Save xbalaji/aad039751ec43e7eb1052d6aabcdaa82 to your computer and use it in GitHub Desktop.
download a single github file
# github-download-file.sh
github_download_file()
{
fileurl=$(echo ${2} | sed -e 's,github.com,api.github.com/repos,;s,blob/master,contents,')
curl -sqk -H "Authorization: token ${1}" -H "Accept: application/vnd.github.v3.raw" -O -L "${fileurl}"
}
# call like: github_download_file $MY_TOKEN "https://github.com/xbalaji/xbenv/blob/master/gvimrc.html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment