Skip to content

Instantly share code, notes, and snippets.

@CurtisAccelerate
Created August 31, 2023 02:23
Show Gist options
  • Save CurtisAccelerate/02d1b68a8cc8d1fa8c091d4ec1ad20b5 to your computer and use it in GitHub Desktop.
Save CurtisAccelerate/02d1b68a8cc8d1fa8c091d4ec1ad20b5 to your computer and use it in GitHub Desktop.
Powershell Ultimate Power
// lsd directory with indexing
// cdx change to index
function Set-IndexedLocation {
param(
[int]$index
)
$dir = (Get-ChildItem -Directory)[$index - 1].FullName
if ($dir) {
Set-Location $dir
} else {
Write-Host "Invalid index"
}
}
Set-Alias -Name cdx -Value Set-IndexedLocation
function lsd {
$directories = Get-ChildItem -Directory
for ($i = 0; $i -lt $directories.Count; $i++) {
Write-Host ("{0}: {1}" -f ($i + 1), $directories[$i].Name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment