mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-11-25 14:07:35 +00:00
Use shell variables instead of env variables
This commit is contained in:
parent
11535a3fb6
commit
3ca89d0e6e
@ -20,23 +20,21 @@ fn __zoxide_cd [path]{
|
||||
# Hook configuration for zoxide.
|
||||
#
|
||||
|
||||
if (not (and (builtin:has-env __zoxide_hooked) (builtin:eq (builtin:get-env __zoxide_hooked) 1))) {
|
||||
builtin:set-env __zoxide_hooked 1
|
||||
# Initialize hook to track previous directory.
|
||||
__zoxide_oldpwd = $pwd
|
||||
before-chdir = [$@before-chdir [_]{ edit:add-var __zoxide_oldpwd $pwd }]
|
||||
|
||||
# Initialize hook to track previous directory.
|
||||
builtin:set-env __zoxide_oldpwd $pwd
|
||||
before-chdir = [$@before-chdir [_]{ builtin:set-env __zoxide_oldpwd $pwd }]
|
||||
{#- __zoxide_hooked requires https://github.com/elves/elvish/issues/1395 #}
|
||||
|
||||
# Initialize hook to add directories to zoxide.
|
||||
# Initialize hook to add directories to zoxide.
|
||||
{%- match hook %}
|
||||
{%- when InitHook::None %}
|
||||
{{ not_configured }}
|
||||
{{ not_configured }}
|
||||
{%- when InitHook::Prompt %}
|
||||
edit:before-readline = [$@edit:before-readline []{ zoxide add -- $pwd }]
|
||||
edit:before-readline = [$@edit:before-readline []{ zoxide add -- $pwd }]
|
||||
{%- when InitHook::Pwd %}
|
||||
after-chdir = [$@after-chdir [_]{ zoxide add -- $pwd }]
|
||||
after-chdir = [$@after-chdir [_]{ zoxide add -- $pwd }]
|
||||
{%- endmatch %}
|
||||
}
|
||||
|
||||
{{ section }}
|
||||
# When using zoxide with --no-aliases, alias these internal functions as
|
||||
@ -48,7 +46,7 @@ fn __zoxide_z [@rest]{
|
||||
if (builtin:eq [] $rest) {
|
||||
__zoxide_cd ~
|
||||
} elif (builtin:eq [-] $rest) {
|
||||
__zoxide_cd (builtin:get-env __zoxide_oldpwd)
|
||||
__zoxide_cd $__zoxide_oldpwd
|
||||
} elif (and ('builtin:==' (builtin:count $rest) 1) (path:is-dir &follow-symlink=$true $rest[0])) {
|
||||
__zoxide_cd $rest[0]
|
||||
} else {
|
||||
@ -97,4 +95,4 @@ edit:add-var zi~ $__zoxide_zi~
|
||||
#
|
||||
# eval (zoxide init elvish | slurp)
|
||||
#
|
||||
# Note that zoxide only supports elvish v0.16.0+.
|
||||
# Note that zoxide only supports elvish v0.16.0 and above.
|
||||
|
Loading…
Reference in New Issue
Block a user