Allow cd . to re-enter the current directory

Closes #4543.
This commit is contained in:
Moritz Wilhelmy 2018-11-04 21:43:12 +08:00 committed by David Adam
parent 7926b69d15
commit 9afc4b419e
2 changed files with 8 additions and 0 deletions

View file

@ -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 <a href="commands.html#prevd">`prevd`</a>. 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

View file

@ -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