Last active
December 19, 2015 08:19
-
-
Save jrotello/5925064 to your computer and use it in GitHub Desktop.
A couple of PowerShell helper functions to interact with http://gitignore.io. These functions will allow you to list the terms recognized by http://gitignore.io as well as generate .gitignore files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# A couple of PowerShell helper functions to interact with | |
# http://gitignore.io. These functions will allow you to | |
# list the terms recognized by http://gitignore.io as well | |
# as generate .gitignore files. | |
# | |
# Install: | |
# Save this file to your machine and dot source it in your PowerShell | |
# profile. | |
function Get-GitIgnore() { | |
<# | |
.SYNOPSIS | |
Generate .gitignore files from http://gitignore.io. | |
.DESCRIPTION | |
Generate .gitignore files from http://gitignore.io. | |
.PARAMETER terms | |
A comma separated list of terms to generate your .gitignore file from. | |
.EXAMPLE | |
Get-GitIgnore visualstudio | |
Preview a .gitignore file suitable for Visual Studio. | |
.EXAMPLE | |
Get-GitIgnore visualstudio > .gitignore | |
Save a .gitignore file suitable for Visual Studio to disk. | |
.EXAMPLE | |
Get-GitIgnore linux,java | |
#> | |
param( | |
[Parameter(Mandatory=$true)] | |
[string[]]$terms | |
) | |
$url = "http://gitignore.io/api/" + [string]::Join(",",$terms) | |
Invoke-RestMethod $url | |
} | |
function List-GitIgnore() { | |
<# | |
.SYNOPSIS | |
List the available terms recognized by http://gitignore.io. | |
.DESCRIPTION | |
List the available terms recognized by http://gitignore.io. | |
.EXAMPLE | |
List-GitIgnore | |
Display all of the terms recognized by http://gitignore.io. | |
#> | |
Get-GitIgnore list | | |
% { $_.Split(",", [StringSplitOptions]::RemoveEmptyEntries) } | | |
Sort-Object | | |
Format-Wide -Property { $_.Trim() } -AutoSize -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment