Skip to content

Instantly share code, notes, and snippets.

@RefusesNames
RefusesNames / Initialize-VS.ps1
Created May 28, 2024 20:26
This function updates paths and sets environment variables the same way a Visual Studio developer console does
function Initialize-VS {
$vsPath = & (Join-Path ${env:ProgramFiles(x86)} "\Microsoft Visual Studio\Installer\vswhere.exe") -property installationpath
if ($vsPath -is [array]) {
$last = $vsPath | Select -Last 1
Import-Module (Join-Path $last "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $last -SkipAutomaticLocation -DevCmdArguments '-arch=amd64 -no_logo'
} else{
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=amd64 -no_logo'
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#F1FA8C",
"properties": {
"style": "folder"
@RefusesNames
RefusesNames / delete-branches.ps1
Last active June 15, 2024 10:07
This function allows to delete local branches that have already been merge to (local) main. To ensure that no important branches are deleted, the names are written to a temporary file that can be edited via nvim. The branches remaining in that file are deleted (except for main)
function delete-branches {
      git switch main
      git branch --merged > tmp.txt
      nvim tmp.txt
      Get-Content tmp.txt | ForEach-Object {
            $to_delete = $_.Trim()
            if ($to_delete -ne "* main" -and $to_delete -ne "main") {
                  echo "Deleting $($to_delete)"
                  git branch -d $to_delete