I would like to cd to some directory without the path to that directory being displayed by powershell. No matter what I try – nothing works:
PS C:\dev\windows\nc> cd .\NC.Server.Host | Out-Null
C:\dev\windows\nc\NC.Server.Host
PS C:\dev\windows\nc\NC.Server.Host> cd .. > $null
C:\dev\windows\nc
PS C:\dev\windows\nc> cd .\NC.Server.Host 2> $null
C:\dev\windows\nc\NC.Server.Host
PS C:\dev\windows\nc\NC.Server.Host> $x=cd ..
C:\dev\windows\nc
PS C:\dev\windows\nc>
As you can see the target directory path is always displayed. Is it a way to avoid it? Thanks.
EDIT
Here is my prompt function:
PS Z:\dev\3rd_party> gc Function:prompt
$(if (test-path variable:/PSDebugContext) { '[DBG]: ' } else { '' }) + 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) + '> '
You probably use the PowerShell Community Extensions. In those
cdis defined as an alias toSet-LocationExwhich exhibits this behaviour:Either use
Set-Locationinstead ofcd, or don’t load PSCX or redefinecdto its usual alias after loading PSCX in your profile.(Those are the reasons I load PSCX only occasionally if I actually need a command from there; redefining core commands or aliases with slightly different semantics is evil and should never be done.)