Skip to content

Instantly share code, notes, and snippets.

@Curtis-64
Last active November 5, 2023 01:36
Show Gist options
  • Save Curtis-64/8e01e465f22c2c3df9cfa7c5d6285bbd to your computer and use it in GitHub Desktop.
Save Curtis-64/8e01e465f22c2c3df9cfa7c5d6285bbd to your computer and use it in GitHub Desktop.
Powershell Power
// Powershell Power by Curtis White
// lsd directory with indexing
// cdx change to index
// Caution: Code is prompted AI generated.
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