set-location — Change directory — navigates filesystem and other providers across all 5 shells
Equivalents in every shell
cd /var/logBuiltin. Bare `cd` jumps to `$HOME`; `cd -` returns to the previous directory (`$OLDPWD`). Path arguments respect `$CDPATH` for "search common parents" behaviour. Symlinks are followed by default; pass `cd -P` to canonicalise to the physical (resolved) path.
cd /var/logBuiltin. Identical to bash plus a directory stack: `cd +1` … `cd +9` (or `cd -N`) jump to entries from `dirs -v`. Set `AUTO_PUSHD` in `.zshrc` to make every `cd` push onto the stack automatically.
cd /var/logBuiltin. `cd -` returns to the previous directory; `cdh` opens an interactive picker over recently-visited directories. Fish has no `$CDPATH`; instead use `set -gx CDPATH ~/projects /etc` for the same parent-search behaviour.
Set-Location C:\UsersAliased as `cd`, `chdir`, `sl`. Works on every PowerShell PROVIDER, not just the file system — `Set-Location HKLM:\Software\Microsoft` walks the registry. Use `-LiteralPath` for paths containing wildcard characters (`[`, `]`).
cd /d D:\projectsBuilt-in. Plain `cd D:\path` only REMEMBERS the path on D: without switching drives — `/d` is required to actually change drive. `cd` with no args prints the current path (NOT $HOME like Unix).
Worked examples
Change to the parent directory
cd ..Set-Location ..cd ..Jump to home directory
cdcdSet-Location ~cd %USERPROFILE%Navigate into the Windows registry
Set-Location HKLM:\Software\Microsoft\WindowsGotchas
- `Set-Location` is provider-aware: `Set-Location HKLM:` enters the registry, `Set-Location Cert:` enters the certificate store. Bash users expecting cd to only touch files are surprised when `Get-ChildItem` after `cd HKLM:` returns registry keys, not file entries.
- The `cd` alias is unchanged on Linux/macOS pwsh hosts — it still calls `Set-Location` rather than dropping to a system `cd` (which doesn't exist as a binary anyway, since `cd` is a bash builtin). Scripts that expect bash semantics need to use `bash -c 'cd … && …'` explicitly.
- `Set-Location -` (previous directory) requires pwsh 6.2+. On Windows PowerShell 5.1, use `Push-Location` / `Pop-Location` to maintain a manual stack, or set `$PWD.PreviousPath` yourself.
- Wildcards: `Set-Location ~\Down*` works (resolves to `~\Downloads` if unique); if it matches more than one path, the cmdlet errors. Always pass `-LiteralPath` when a directory name contains `[` or `]`.
- Provider state is per-runspace: in `ForEach-Object -Parallel` (pwsh 7+), each parallel thread starts with the runspace's initial location, NOT the caller's current location. Pass `$using:PWD` and re-`Set-Location` inside the block if you need shared cwd.