.\" Man page generated from reStructuredText .\" by the Docutils 0.23 manpage writer. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "CD" "1" "Oct 10, 2026" "4.9" "fish-shell" .SH NAME cd \- change directory .SH SYNOPSIS .nf \fBcd\fP [( \fB\-L\fP | \fB\-\-no\-dereference\fP ) | ( \fB\-P\fP | \fB\-\-dereference\fP )] [\fIDIRECTORY\fP] .fi .sp .SH DESCRIPTION .sp NOTE: This page documents the fish builtin \fBcd\fP\&. To see the documentation on any non\-fish versions, use \fBcommand man cd\fP\&. .sp \fBcd\fP changes the current working directory. .sp The \fBPWD\fP \%<#\:envvar-PWD> environment variable is updated with the new working directory, and the previous directory is added to the directory history \%<#\:directory-history>\&. .sp If \fIDIRECTORY\fP is given, it will become the new directory. If no parameter is given, the \fBHOME\fP \%<#\:envvar-HOME> environment variable will be used. .sp If \fIDIRECTORY\fP is a relative path, all the paths in the \fBCDPATH\fP \%<#\:envvar-CDPATH> will be tried as prefixes for it, in addition to \fBPWD\fP \%<#\:envvar-PWD>\&. It is recommended to keep \fB\&.\fP as the first element of \fBCDPATH\fP \%<#\:envvar-CDPATH>, or \fBPWD\fP \%<#\:envvar-PWD> will be tried last. .sp The new directory name is partially resolved to remove redundant segments (\fB\&.\fP or \fB\&..\fP). .sp \fBcd\fP defaults to treating symbolic links as real directories, and not resolving them to their underlying targets. The \fB$PWD\fP special variable \%<#\:variables-special> variable will contain the path that was supplied. This default behaviour can be enforced with the \fB\-L\fP or \fB\-\-no\-dereference\fP option. .sp The \fB\-P\fP or \fB\-\-dereference\fP option resolves all symbolic links first. This was the default in fish versions before 3.0.0. .sp fish will also try to change directory if given a command that looks like a directory (starting with \fB\&.\fP, \fB/\fP or \fB~\fP, or ending with \fB/\fP), without explicitly requiring \fBcd\fP\&. .sp fish also ships a wrapper function around the builtin \fBcd\fP that understands \fBcd \-\fP as changing to the previous directory. See also prevd \%<>\&. This wrapper function maintains a history of the 25 most recently visited directories in the \fB$dirprev\fP and \fB$dirnext\fP global variables. If you make those universal variables your \fBcd\fP history is shared among all fish instances. .sp As a special case, \fBcd .\fP is equivalent to \fBcd $PWD\fP, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated. .sp The \fB\-\-help\fP or \fB\-h\fP option displays help about using this command, and does not change the directory. .SH EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .EX 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 .EE .UNINDENT .UNINDENT .SH SEE ALSO .sp Navigate directories using the directory history \%<#\:directory-history> or the directory stack \%<#\:directory-stack> .SH Copyright fish-shell developers .\" End of generated man page.