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
This commit is contained in:
parent
75496f76cd
commit
d219cd1479
@ -1,4 +1,4 @@
|
|||||||
# Remove these aliases to PowerShell builtins which clobber the actaul exes.
|
# Remove builtin aliases
|
||||||
Remove-Item alias:curl
|
Remove-Item Alias:curl
|
||||||
Remove-Item alias:wget
|
Remove-Item Alias:wget
|
||||||
# TODO: Remove default abbriviation aliases
|
Remove-Item Alias:cd
|
||||||
|
@ -11,4 +11,5 @@ $OutputEncoding = New-Object -typename System.Text.UTF8Encoding
|
|||||||
. $PSScriptRoot\alias.ps1
|
. $PSScriptRoot\alias.ps1
|
||||||
. $PSScriptRoot\utils.ps1
|
. $PSScriptRoot\utils.ps1
|
||||||
. $PSScriptRoot\layout.ps1
|
. $PSScriptRoot\layout.ps1
|
||||||
# TODO: $PSScriptRoot\build.ps1
|
# TODO: . $PSScriptRoot\build.ps1
|
||||||
|
# TODO: . $PSScriptRoot\autoenv.ps1
|
||||||
|
16
utils.ps1
16
utils.ps1
@ -1,2 +1,16 @@
|
|||||||
# TODO: Define cd to work with zero args for home and - for last directory
|
# 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
|
# TODO: Define rm to work with -rf and multiple entries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user