Skip to content

Instantly share code, notes, and snippets.

@moritz-t-w
Last active December 26, 2022 19:15
Show Gist options
  • Save moritz-t-w/759ee18e67b43811eb2136562fbfb0e6 to your computer and use it in GitHub Desktop.
Save moritz-t-w/759ee18e67b43811eb2136562fbfb0e6 to your computer and use it in GitHub Desktop.
Creates a git / github / vscode repo with a basic structure
function New-Repo {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[string]$RepoName = "New Repo",
[Parameter(Mandatory = $false)]
[string]$License = "mit",
[Parameter(Mandatory = $false)]
[string]$RepoPath = "$env:UserProfile\Documents\GitHub",
)
$repoPath = "$RepoPath\$RepoName"
New-Item -ItemType Directory -Path $repoPath | Out-Null
Push-Location $repoPath
New-Item -ItemType Directory -Path "src" | Out-Null
New-Item -ItemType Directory -Path "doc" | Out-Null
New-Item -ItemType Directory -Path "test" | Out-Null
New-Item -ItemType Directory -Path "build" | Out-Null
Invoke-WebRequest "https://spdx.org/licenses/$License.txt" -OutFile "LICENSE"
Invoke-WebRequest "https://www.gitignore.io/api/visualstudiocode" -OutFile ".gitignore"
Add-Content ".gitignore" "build/"
New-Item -ItemType File -Path "README.md" | Out-Null
Invoke-Expression "git init"
Invoke-Expression "git add ."
Start-Process "code" "."
Pop-Location
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment