Skip to content

Instantly share code, notes, and snippets.

@pizycki
Created September 28, 2019 12:58
Show Gist options
  • Select an option

  • Save pizycki/d7cdf517e8af7de7a3dd8f2b7fc41f9a to your computer and use it in GitHub Desktop.

Select an option

Save pizycki/d7cdf517e8af7de7a3dd8f2b7fc41f9a to your computer and use it in GitHub Desktop.
Creates gitignore file
function New-GitIgnore {
param(
[switch] $All = $false,
[switch] $VisualStudio = $false,
[switch] $VisualStudioCode = $false,
[switch] $Rider = $false,
[switch] $InteliJ = $false
)
$url = "https://gitignore.io/api/"
$originalUrlLength = $url.Length
if($All -or $VisualStudio) { $url = $url + "visualstudio," }
if($All -or $VisualStudioCode) { $url = $url + "visualstudiocode," }
if($All -or $InteliJ) { $url = $url + "intellij+all," }
if($All -or $Rider) { $url = $url + "rider," }
$url = $url.TrimEnd(',')
if($url.Length -eq $originalUrlLength){
Write-Host -ForegroundColor Yellow "You must provide at least one option to generate gitignore file."
return
}
$exp = "wget `"$($url)`" -OutFile .gitignore."
Write-Host $exp
Invoke-Expression $exp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment