Fix zi function

This commit is contained in:
Ajeet D'Souza 2020-05-29 03:37:15 +05:30
parent 9b056fb58c
commit d8a29f4367
3 changed files with 27 additions and 17 deletions

View File

@ -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'

View File

@ -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'

View File

@ -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 }}