mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Honor dirprev scope (#5796)
* Honour `dirprev` scope Honour the scope of the `dirprev` variable if it is universal and avoid to shadow it with a global. This enables to share the `cd` history between sessions. * Honor dirnext and __fish_cd_direction scope If these variables exist in the universal scope, do not shadow them
This commit is contained in:
parent
898ed12a6c
commit
9cf1b18b26
1 changed files with 15 additions and 3 deletions
|
@ -41,9 +41,21 @@ function cd --description "Change directory"
|
||||||
or set -l dirprev
|
or set -l dirprev
|
||||||
set -q dirprev[$MAX_DIR_HIST]
|
set -q dirprev[$MAX_DIR_HIST]
|
||||||
and set -e dirprev[1]
|
and set -e dirprev[1]
|
||||||
set -g -a dirprev $previous
|
|
||||||
set -e dirnext
|
# If dirprev, dirnext, __fish_cd_direction
|
||||||
set -g __fish_cd_direction prev
|
# are set as universal variables, honour their scope.
|
||||||
|
|
||||||
|
set -U -q dirprev
|
||||||
|
and set -U -a dirprev $previous
|
||||||
|
or set -g -a dirprev $previous
|
||||||
|
|
||||||
|
set -U -q dirnext
|
||||||
|
and set -U -e dirnext
|
||||||
|
or set -e dirnext
|
||||||
|
|
||||||
|
set -U -q __fish_cd_direction
|
||||||
|
and set -U __fish_cd_direction prev
|
||||||
|
or set -g __fish_cd_direction prev
|
||||||
end
|
end
|
||||||
|
|
||||||
return $cd_status
|
return $cd_status
|
||||||
|
|
Loading…
Reference in a new issue