feat(std/dirs): retain state in subshells or with exec-restarts (#15080)

Persist `std/dirs`'s state in subshells and also when restarting the
shell with `exec $nu.current-exe`
This commit is contained in:
Bahex
2025-02-12 03:51:43 +03:00
committed by GitHub
parent f7d5162582
commit d577074da9
2 changed files with 19 additions and 3 deletions

View File

@ -17,8 +17,16 @@
# This situation could arise if we started with [/a, /b, /c], then
# we changed directories from /b to /var/tmp.
export-env {
$env.DIRS_POSITION = 0
$env.DIRS_LIST = [($env.PWD | path expand)]
$env.ENV_CONVERSIONS.DIRS_LIST = {
from_string: {|| split row (char esep)}
to_string: {|| str join (char esep)}
}
$env.ENV_CONVERSIONS.DIRS_POSITION = {
from_string: {|| into int}
to_string: {|| into string}
}
$env.DIRS_POSITION = $env.DIRS_POSITION? | default (0)
$env.DIRS_LIST = $env.DIRS_LIST? | default [($env.PWD | path expand)]
}
# Add one or more directories to the list.
@ -145,4 +153,4 @@ export module shells-aliases {
export alias p = prev
export alias n = next
export alias g = goto
}
}