CD(1)
πΏ CD(1) β fish-shell's cd, bestie edition β¨
okay so real talk, this page is about the fish builtin cd π
β like, the fish-shell version specifically. Wanna see the docs for some non-fish cd? go run command man cd instead, no cap.
β¨ SYNOPSIS β¨
cd [( -L | --no-dereference ) | ( -P | --dereference )] [DIRECTORY]
πΈ DESCRIPTION πΈ
cd changes the current working directory. that's it, that's the whole vibe. π«Ά
The PWD environment variable gets updated with your new working directory, and the previous directory gets added to the directory history. so nothing is ever really lost, it's giving "no delete, only archive" π
DIRECTORYβ if you pass it, it becomes your new directory. if you pass nothing, theHOMEenvironment variable is what gets used. home sweet home, literally π
If DIRECTORY is a relative path, every path in CDPATH gets tried as a prefix for it, in addition to PWD. and like β highly recommend keeping . as the first element of CDPATH, otherwise PWD gets tried last. consider this your friendly reminder π
The new directory name is partially resolved to remove redundant segments (. or ..). we love a tidy path β¨
cd defaults to treating symbolic links as real directories, and not resolving them to their underlying targets. the $PWD special variable will contain the path that was supplied. this default behaviour can be enforced with the -L or --no-dereference option. slay, keep your symlinks as symlinks π
π¦ the dereference options
-L,--no-dereferenceβ enforce the default: treat symbolic links as real directories, don't resolve them to their targets.$PWDkeeps the path you supplied π-P,--dereferenceβ resolves all symbolic links first. important lore: this was the default in fish versions before 3.0.0 π-h,--helpβ displays help about using this command and does not change the directory. literally just reads the group chat, doesn't reply π
β other iconic behaviours
fish will also try to change directory if you give it a command that looks like a directory β starting with ., / or ~, or ending with / β without explicitly requiring cd. it just knows. iykyk π§
fish also ships a wrapper function around the builtin cd that understands cd - as changing to the previous directory. see also prevd. this wrapper function maintains a history of the 25 most recently visited directories in the $dirprev and $dirnext global variables. and like β if you make those universal variables, your cd history is shared among all fish instances. main character energy for your whole terminal ππ
as a special case, cd . is equivalent to cd $PWD, which is genuinely useful in cases where a mountpoint has been recycled or a directory has been removed and recreated. lowkey a lifesaver π₯
π EXAMPLES π
cd
# changes the working directory to your home directory.
cd /usr/src/fish-shell
# changes the working directory to /usr/src/fish-shell
cd -P /tmp/link
# resolves /tmp/link to its target before recording the directory
π SEE ALSO π
- Navigate directories using the directory history or the directory stack πΈ
π Copyright π
fish-shell developers β respect the icons π«‘
okay bestie that's the whole page, go forth and cd responsibly π
β¨
sign-off time: this lil doc is from the fish-shell fam, version 4.9, dated Sep 08, 2026 β screenshot it, quote it, live by it ππ¦π
π¦ where this page comes from
- arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms