Avoid namespacing local variables
This commit is contained in:
parent
864951b928
commit
d65b0021b3
|
|
@ -70,15 +70,15 @@ function __zoxide_z
|
|||
end
|
||||
__zoxide_cd $argv[1]
|
||||
else
|
||||
set -l __zoxide_result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
|
||||
and __zoxide_cd $__zoxide_result
|
||||
set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
|
||||
and __zoxide_cd $result
|
||||
end
|
||||
end
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
function __zoxide_zi
|
||||
set -l __zoxide_result (command zoxide query -i -- $argv)
|
||||
and __zoxide_cd $__zoxide_result
|
||||
set -l result (command zoxide query -i -- $argv)
|
||||
and __zoxide_cd $result
|
||||
end
|
||||
|
||||
{{ section }}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ function __zoxide_cd($dir) {
|
|||
|
||||
# Hook to add new entries to the database.
|
||||
function __zoxide_hook {
|
||||
$__zoxide_result = __zoxide_pwd
|
||||
if ($__zoxide_result -ne $null) {
|
||||
zoxide add -- $__zoxide_result
|
||||
$result = __zoxide_pwd
|
||||
if ($result -ne $null) {
|
||||
zoxide add -- $result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,10 +43,10 @@ if ($__zoxide_hooked -ne 1) {
|
|||
{%- when InitHook::None %}
|
||||
{{ not_configured }}
|
||||
{%- when InitHook::Prompt %}
|
||||
$__zoxide_prompt_old = $function:prompt
|
||||
$prompt_old = $function:prompt
|
||||
function prompt {
|
||||
$null = __zoxide_hook
|
||||
& $__zoxide_prompt_old
|
||||
& $prompt_old
|
||||
}
|
||||
{%- when InitHook::Pwd %}
|
||||
if ($PSVersionTable.PSVersion.Major -ge 6) {
|
||||
|
|
@ -78,23 +78,23 @@ function __zoxide_z {
|
|||
__zoxide_cd $args[0]
|
||||
}
|
||||
else {
|
||||
$__zoxide_result = __zoxide_pwd
|
||||
if ($__zoxide_result -ne $null) {
|
||||
$__zoxide_result = zoxide query --exclude $__zoxide_result -- @args
|
||||
$result = __zoxide_pwd
|
||||
if ($result -ne $null) {
|
||||
$result = zoxide query --exclude $result -- @args
|
||||
} else {
|
||||
$__zoxide_result = zoxide query -- @args
|
||||
$result = zoxide query -- @args
|
||||
}
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
__zoxide_cd $__zoxide_result
|
||||
__zoxide_cd $result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
function __zoxide_zi {
|
||||
$__zoxide_result = zoxide query -i -- @args
|
||||
$result = zoxide query -i -- @args
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
__zoxide_cd $__zoxide_result
|
||||
__zoxide_cd $result
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def __zoxide_z(args: List[str]):
|
|||
else:
|
||||
try:
|
||||
zoxide = __zoxide_bin()
|
||||
__zoxide_cmd = subprocess.run(
|
||||
cmd = subprocess.run(
|
||||
[zoxide, "query", "--exclude", __zoxide_pwd(), "--"] + args,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
|
|
@ -122,22 +122,22 @@ def __zoxide_z(args: List[str]):
|
|||
except subprocess.CalledProcessError as exc:
|
||||
raise ZoxideSilentException() from exc
|
||||
|
||||
__zoxide_result = __zoxide_cmd.stdout[:-1]
|
||||
__zoxide_cd(__zoxide_result)
|
||||
result = cmd.stdout[:-1]
|
||||
__zoxide_cd(result)
|
||||
|
||||
|
||||
def __zoxide_zi(args: List[str]):
|
||||
"""Jump to a directory using interactive search."""
|
||||
try:
|
||||
zoxide = __zoxide_bin()
|
||||
__zoxide_cmd = subprocess.run(
|
||||
cmd = subprocess.run(
|
||||
[zoxide, "query", "-i", "--"] + args, check=True, stdout=subprocess.PIPE
|
||||
)
|
||||
except subprocess.CalledProcessError as exc:
|
||||
raise ZoxideSilentException() from exc
|
||||
|
||||
__zoxide_result = __zoxide_cmd.stdout[:-1]
|
||||
__zoxide_cd(__zoxide_result)
|
||||
result = cmd.stdout[:-1]
|
||||
__zoxide_cd(result)
|
||||
|
||||
|
||||
{{ section }}
|
||||
|
|
|
|||
|
|
@ -62,16 +62,16 @@ function __zoxide_z() {
|
|||
elif [ "$#" -eq 1 ] && [ -d "$1" ]; then
|
||||
__zoxide_cd "$1"
|
||||
else
|
||||
\builtin local __zoxide_result
|
||||
__zoxide_result="$(zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" \
|
||||
&& __zoxide_cd "${__zoxide_result}"
|
||||
\builtin local result
|
||||
result="$(zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" \
|
||||
&& __zoxide_cd "${result}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
function __zoxide_zi() {
|
||||
\builtin local __zoxide_result
|
||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||
\builtin local result
|
||||
result="$(zoxide query -i -- "$@")" && __zoxide_cd "${result}"
|
||||
}
|
||||
|
||||
{{ section }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue