WindowsPowerShell/utils.ps1
Kenneth Benzie (Benie) d219cd1479 Replace default cd alias with cd function
Define cd to work more like Unix/Linux:

* No path argument changes to the users home directory
* Passing "-" for the path argument changes to the previous directory
2024-12-13 21:55:41 +00:00

17 lines
472 B
PowerShell

# Define cd to work more like Unix/Linux:
# * No path argument changes to the users home directory
# * Passing "-" for the path argument changes to the previous directory
$Global:cdPreviousPath = Get-Location
function cd {
Param ([string]$Path)
if ($Path -eq "") {
$Path = "~"
} elseif ($Path -eq "-") {
$Path = $cdPreviousPath
}
$Global:cdPreviousPath = Get-Location
Set-Location -Path $Path
}
# TODO: Define rm to work with -rf and multiple entries