diff --git a/src/subcommand/init/shell/fish.rs b/src/subcommand/init/shell/fish.rs index 730f6d2..32491db 100644 --- a/src/subcommand/init/shell/fish.rs +++ b/src/subcommand/init/shell/fish.rs @@ -27,7 +27,7 @@ function _z_cd end end -function {} +function {0} set argc (count $argv) if test $argc -eq 0 @@ -39,6 +39,11 @@ function {} and _z_cd $_zoxide_result end end + +function {0}i + set -l result (zoxide query -i -- $argv) + and _z_cd $result +end "#, cmd ) @@ -47,8 +52,6 @@ end fn alias(cmd: &str) -> String { format!( r#" -abbr -a {0}i '{0} -i' - abbr -a {0}a 'zoxide add' abbr -a {0}q 'zoxide query' diff --git a/src/subcommand/init/shell/posix.rs b/src/subcommand/init/shell/posix.rs index d052835..240c253 100644 --- a/src/subcommand/init/shell/posix.rs +++ b/src/subcommand/init/shell/posix.rs @@ -26,7 +26,7 @@ _z_cd() {{ fi }} -{}() {{ +{0}() {{ if [ "$#" -eq 0 ]; then _z_cd ~ elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then @@ -40,6 +40,10 @@ _z_cd() {{ _zoxide_result="$(zoxide query -- "$@")" && _z_cd "$_zoxide_result" fi }} + +{0}i() {{ + result="$(zoxide query -i -- "$@")" && _z_cd "$result" +}} "#, cmd ) @@ -48,8 +52,6 @@ _z_cd() {{ fn alias(cmd: &str) -> String { format!( r#" -alias {0}i='{0} -i' - alias {0}a='zoxide add' alias {0}q='zoxide query' diff --git a/src/subcommand/init/shell/powershell.rs b/src/subcommand/init/shell/powershell.rs index ac220d4..b0bbee4 100644 --- a/src/subcommand/init/shell/powershell.rs +++ b/src/subcommand/init/shell/powershell.rs @@ -16,27 +16,34 @@ pub const CONFIG: ShellConfig = ShellConfig { fn z(cmd: &str) -> String { format!( r#" -function {} {{ - function z_cd($dir) {{ - Set-Location $dir -ea Stop - if ($env:_ZO_ECHO -eq "1") {{ - Write-Host "$PWD" - }} +function _z_cd($dir) {{ + Set-Location $dir -ea Stop + if ($env:_ZO_ECHO -eq "1") {{ + Write-Host "$PWD" }} +}} +function {0} {{ if ($args.Length -eq 0) {{ - z_cd ~ + _z_cd ~ }} elseif ($args.Length -eq 1 -and $args[0] -eq '-') {{ - z_cd - + _z_cd - }} else {{ $_zoxide_result = zoxide query -- @args if ($LASTEXITCODE -eq 0) {{ - z_cd $_zoxide_result + _z_cd $_zoxide_result }} }} }} + +function {0}i {{ + $result = zoxide query -i -- @args + if ($LASTEXITCODE -eq 0) {{ + _z_cd $result + }} +}} "#, cmd ) @@ -45,8 +52,6 @@ function {} {{ fn alias(cmd: &str) -> String { format!( r#" -function {0}i {{ {0} -i @args }} - function {0}a {{ zoxide add @args }} function {0}q {{ zoxide query @args }}