Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Last active October 10, 2023 20:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loic-sharma/4782d0bceeee961bc25a0429a1afa899 to your computer and use it in GitHub Desktop.
Save loic-sharma/4782d0bceeee961bc25a0429a1afa899 to your computer and use it in GitHub Desktop.
Scripts to setup development VM
# Requires:
# Set-ExecutionPolicy RemoteSigned -s CurrentUser
# Install apps
iex (New-Object Net.WebClient).DownloadString('https://get.scoop.sh')
scoop install git
scoop bucket add extras
scoop install vscode
scoop install sqlopsstudio
scoop install storageexplorer
$gist = 'https://gist.githubusercontent.com/loic-sharma/4782d0bceeee961bc25a0429a1afa899/raw/82165f0d4ba58a08eeb32ea379d3def1fdff48ca'
# Add PowerShell profile script
mkdir (Split-Path $profile)
(New-Object Net.WebClient).DownloadFile("$($gist)/profile.ps1", $profile)
# Add VSCode to Context Menus
(New-Object Net.WebClient).DownloadFile("$($gist)/vscode.reg", "$($env:temp)\\vscode.reg")
& reg import "$($env:temp)\\vscode.reg"
# Configure git
git config --global user.email "sharma.loic@gmail.com"
git config --global user.name "Loic Sharma"
git config --global alias.st status
git config --global alias.b branch
git config --global alias.co checkout
# Install codebases
mkdir ~\Code
cd ~\Code
git clone https://github.com/NuGet/NuGet.Client.git
git clone https://github.com/NuGet/NuGet.Jobs.git
git clone https://github.com/NuGet/NuGet.Services.EndToEnd.git
git clone https://github.com/NuGet/NuGet.Services.Metadata.git
git clone https://github.com/NuGet/NuGetGallery.git
git clone https://github.com/NuGet/ServerCommon.git
# Paths
function Go-ToCode { Set-Location -Path C:\Users\loshar\Code }
function Go-ToNuGetGallery { Set-Location -Path C:\Users\loshar\Code\NuGetGallery }
function Go-ToNuGetJobs { Set-Location -Path C:\Users\loshar\Code\NuGet.Jobs }
function Go-ToNuGetServerCommon { Set-Location -Path C:\Users\loshar\Code\ServerCommon }
function Go-ToNuGetMetadata { Set-Location -Path C:\Users\loshar\Code\NuGet.Services.Metadata }
function Go-ToNuGetDeployment { Set-Location -Path C:\Users\loshar\Code\NuGetDeployment }
Set-Alias -Name c -Value Go-ToCode
Set-Alias -Name g -Value Go-ToNuGetGallery
Set-Alias -Name j -Value Go-ToNuGetJobs
Set-Alias -Name m -Value Go-ToNuGetMetadata
Set-Alias -Name d -Value Go-ToNuGetDeployment
# Git Helpers
function Get-GitStatus { &git status $args }
function Get-GitBranch { &git branch $args }
function Get-GitCheckout { &git checkout $args }
function Get-GitDiff { &git diff $args }
function Get-GitAdd { &git add $args }
Set-Alias -Name st -Value Get-GitStatus
Set-Alias -Name b -Value Get-GitBranch
Set-Alias -Name co -Value Get-GitCheckout
Set-Alias -Name dif -Value Get-GitDiff
Set-Alias -Name add -Value Get-GitAdd
# Misc Helpers
function Open-Solution { .\*.sln }
Set-Alias -Name sln -Value Open-Solution
Set-PSReadlineKeyHandler -Key Tab -Function Complete
# Git Merge Clean
function Clean-GitMerge {
$origFiles = Get-ChildItem -Path *.orig -Recurse -Force
if ($origFiles.Length -eq 0) {
Write-Host "No .orig files found"
}
$origFiles | % {
$answer = Read-Host -Prompt "Delete '$($_)'? [y/n]"
$answer = $answer.Trim().ToLower();
if ($answer -eq 'y' -or $answer -eq 'yes') {
Remove-Item -Path $_
Write-Host "Deleted '$($_)'"
Write-Host ""
}
else {
Write-Host "Skipped '$($_)'"
Write-Host ""
}
}
}
Windows Registry Editor Version 5.00
; Modified from: http://thisdavej.com/right-click-on-windows-folder-and-open-with-visual-studio-code/
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\loshar\\scoop\\apps\\vscode\\current\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\loshar\\scoop\\apps\\vscode\\current\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\loshar\\scoop\\apps\\vscode\\current\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\loshar\\scoop\\apps\\vscode\\current\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\loshar\\scoop\\apps\\vscode\\current\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\loshar\\scoop\\apps\\vscode\\current\\Code.exe\" \"%V\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment