CDPath
Specify the same cd search paths cross shell.
Syntaxโ
cdpath:
- value: |
{{ .Home }}/src
{{ .Home }}/work
if: match .Shell "bash" "zsh" "fish" "tcsh" "xonsh"
- value: |
{{ .Home }}/sandbox
ifExists: true
force: true
CDPathโ
value(string): directory entries to add, separated by newlines. Supports templating.if(string): golang template conditional statement, see if.force(boolean): always export the entry even when already present in the current shell.ifExists(boolean): add only entries that exist on disk (default:false).
Shell behavior:
| Shell | Supported | Implementation |
|---|---|---|
bash | Yes | Appends to the CDPATH environment variable |
zsh | Yes | Appends to the cdpath shell variable |
fish | Yes | Appends using set -g cdpath $cdpath <value> |
tcsh | Yes | Appends to the cdpath shell variable |
xonsh | Yes | Appends to $CDPATH |
cmd | No | Skipped |
pwsh | No | Skipped |
powershell | No | Skipped |
nu | No | Skipped |
High-level behavior:
aliaeuses shell-nativecdsearch path mechanisms where available.- Each configured entry is appended to the active shell's
CDPATH/cdpathrepresentation. aliaeprepends.when needed so local-directory fallback remains available.- Duplicate entries are suppressed and existing shell values are preserved.
ifExistsandforcework the same way as they do forpath.
cdpath entries follow the same duplicate suppression and path normalization behavior as path.
Expected output by shellโ
The examples below use:
cdpath:
- value: /usr/local/share
- bash
- zsh
- fish
- tcsh
- xonsh
export CDPATH="${CDPATH:+$CDPATH:}/usr/local/share"
cdpath=( $cdpath /usr/local/share )
set -g cdpath $cdpath /usr/local/share
set cdpath = ( $cdpath /usr/local/share );
$CDPATH = $CDPATH + ["/usr/local/share"]
cdpath output is not emitted for cmd, pwsh, powershell, or nu.