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