From d65b0021b3afaa763264a611926313e660d2284c Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sat, 4 Sep 2021 00:53:54 +0530 Subject: [PATCH] Avoid namespacing local variables --- templates/fish.txt | 8 ++++---- templates/powershell.txt | 24 ++++++++++++------------ templates/xonsh.txt | 12 ++++++------ templates/zsh.txt | 10 +++++----- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/templates/fish.txt b/templates/fish.txt index 6cae56a..7f33c3d 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -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 }} diff --git a/templates/powershell.txt b/templates/powershell.txt index d4d77ab..31a462f 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -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 } } diff --git a/templates/xonsh.txt b/templates/xonsh.txt index c5fb157..bb795cf 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -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 }} diff --git a/templates/zsh.txt b/templates/zsh.txt index 6bee5fd..85da631 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -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 }}