diff --git a/doc_src/cd.txt b/doc_src/cd.txt index caffa842c..748f0c322 100644 --- a/doc_src/cd.txt +++ b/doc_src/cd.txt @@ -16,6 +16,8 @@ Note that the shell will attempt to change directory without requiring `cd` if t 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. If you make those universal variables your `cd` history is shared among all fish instances. +As a special case, `cd .` is equivalent to `cd $PWD`, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated. + \subsection cd-example Examples \fish diff --git a/share/functions/cd.fish b/share/functions/cd.fish index 23f169d2c..eed8a9f94 100644 --- a/share/functions/cd.fish +++ b/share/functions/cd.fish @@ -27,6 +27,12 @@ function cd --description "Change directory" return $status end + # allow explicit "cd ." if the mount-point became stale in the meantime + if test "$argv" = "." + cd "$PWD" + return $status + end + builtin cd $argv set -l cd_status $status