Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active June 23, 2017 13:45
Show Gist options
  • Save turboBasic/5ba8aa940d117432cbd48a3603e1aec0 to your computer and use it in GitHub Desktop.
Save turboBasic/5ba8aa940d117432cbd48a3603e1aec0 to your computer and use it in GitHub Desktop.
Get links to gists, Powershell version. Get links to gists of active github user
<#
Get list of public gists from GitHub
Dependencies: Powershell v3+
ConvertTo-Hashtable: see in my gists
2017 Andriy Melnyk https://github.com/TurboBasic
#>
$DEFAULT_API = 'https://api.github.com/gists'
#$DEFAULT_API = 'https://api.github.com/users/USERNAME/gists'
Function Get-Gist( [string]$api = 'https://api.github.com/gists' ) {
(curl $api |
select -expandProperty Content |
ConvertFrom-Json) | Foreach-Object {
$_currentRecord=$_
$_.files | ConvertTo-Hashtable |
Select -expandProperty Values |
Foreach-Object {
[PSCustomObject]@{
id = $_currentRecord.id;
description = $_currentRecord.description;
filename = $_.filename;
url = $_.raw_url
}
}
} | Format-List filename, url, description
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment