ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
20.29k stars 518 forks source link

Unable to initialize zoxide in my zsh #792

Open moheladwy opened 2 months ago

moheladwy commented 2 months ago

I put this command eval "$(zoxide init zsh)" in my .zshrc at the bottom of the file as the README said, When I open the terminal I got this error "(eval):51: parse error near `}" at the startup of the terminal, I run the command and exported in an external file and then opened it, I found out that the problem with the function __zoxide_z(), the line 51 was the } at the end of the this function.

function __zoxide_z()  {
    # shellcheck disable=SC2199
    if [[ "$#" -eq 0 ]]; then
        __zoxide_cd ~
    elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then
        __zoxide_cd "$1"
    else
        \builtin local result
        # shellcheck disable=SC2312
        result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" && __zoxide_cd "${result}"
    fi
}

i don't know what is the problem with this function actually. How can I solve this problem?

ajeetdsouza commented 2 months ago

What version of zsh are you using? You might need to upgrade it.

zsh --version
moheladwy commented 2 months ago

@ajeetdsouza The Version of the zsh on my system (arch-linux) is 5.9

image