Powershell snippets

Open the profile file in VSCode

code $profile

Reload the profile:

. $profile

Helpers to recycle files in Windows:

function Recycle {
    Param(
        [Parameter(Mandatory = $true, HelpMessage = 'The root directory')]
        [String]$Path)

    Add-Type -AssemblyName Microsoft.VisualBasic

    $FullName = (Get-Item -Path $Path).fullname

    Write-Host "Recycle $FullName"
    if (Test-Path -Path $FullName -PathType Container) {
        [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory($FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')
    }
    else {
        [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')
    }
}

function RecycleDevFolders {
    Param(
        [Parameter(Mandatory = $true, HelpMessage = 'The root directory')]
        [String]$Root)

    Add-Type -AssemblyName Microsoft.VisualBasic

    $TargetFolders = Get-ChildItem -Path $Root -Include target, __pycache__, .ipynb_checkpoints -Recurse 
    
    foreach ($Path in $TargetFolders) {
        $FullName = $Path.fullname
        Write-Host "Recycle $FullName"
        [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory($FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')
    }
}