ajeetdsouza / zoxide

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

Bug: Shows "zoxide: no match found" on every directory change #487

Closed raguay closed 1 year ago

raguay commented 1 year ago

I'm trying to use zoxide, but it prints "zoxide: no match found" everything I change directories. My setup is a MacBook Pro M1 chip system with Ventura 13.0.1 (22A400), fish version 3.5.1, and my config for it in fish is:

# Path to Oh My Fish install.
set -q XDG_DATA_HOME
  and set -gx OMF_PATH "$XDG_DATA_HOME/omf"
  or set -gx OMF_PATH "$HOME/.local/share/omf"

# Load Oh My Fish configuration.
source $OMF_PATH/init.fish

# Load Posh
set -gx POSHTHEME dracula.omp.json
#set -gx POSHCONFIG (brew --prefix oh-my-posh)/themes/$POSHTHEME
set -gx POSHCONFIG /Users/raguay/.config/ohmyposh/$POSHTHEME
oh-my-posh init fish --config $POSHCONFIG | source

# setup zoxide
zoxide init fish | source

# Hishtory Config:
export PATH="$PATH:/Users/raguay/.hishtory"
source /Users/raguay/.hishtory/config.fish

The output of the zoxide init fish is:

# =============================================================================
#
# Utility functions for zoxide.
#

# pwd based on the value of _ZO_RESOLVE_SYMLINKS.
function __zoxide_pwd
    builtin pwd -L
end

# A copy of fish's internal cd function. This makes it possible to use
# `alias cd=z` without causing an infinite loop.
if ! builtin functions -q __zoxide_cd_internal
    if builtin functions -q cd
        builtin functions -c cd __zoxide_cd_internal
    else
        alias __zoxide_cd_internal='builtin cd'
    end
end

# cd + custom logic based on the value of _ZO_ECHO.
function __zoxide_cd
    __zoxide_cd_internal $argv
end

# =============================================================================
#
# Hook configuration for zoxide.
#

# Initialize hook to add new entries to the database.
function __zoxide_hook --on-variable PWD
    test -z "$fish_private_mode"
    and command zoxide add -- (__zoxide_pwd)
end

# =============================================================================
#
# When using zoxide with --no-cmd, alias these internal functions as desired.
#

set __zoxide_z_prefix 'z!'

# Jump to a directory using only keywords.
function __zoxide_z
    set -l argc (count $argv)
    set -l completion_regex '^'(string escape --style=regex $__zoxide_z_prefix)'(.*)$'

    if test $argc -eq 0
        __zoxide_cd $HOME
    else if test "$argv" = -
        __zoxide_cd -
    else if test $argc -eq 1 -a -d $argv[1]
        __zoxide_cd $argv[1]
    else if set -l result (string match --groups-only --regex $completion_regex $argv[-1])
        __zoxide_cd $result
    else
        set -l result (command zoxide query --exclude (__zoxide_pwd) -- $argv)
        and __zoxide_cd $result
    end
end

# Completions for `z`.
function __zoxide_z_complete
    set -l tokens (commandline --current-process --tokenize)
    set -l curr_tokens (commandline --cut-at-cursor --current-process --tokenize)

    if test (count $tokens) -le 2 -a (count $curr_tokens) -eq 1
        # If there are < 2 arguments, use `cd` completions.
        __fish_complete_directories "$tokens[2]" ''
    else if test (count $tokens) -eq (count $curr_tokens)
        # If the last argument is empty, use interactive selection.
        set -l query $tokens[2..-1]
        set -l result (zoxide query --exclude (__zoxide_pwd) -i -- $query)
        and echo $__zoxide_z_prefix$result
        commandline --function repaint
    end
end

# Jump to a directory using interactive search.
function __zoxide_zi
    set -l result (command zoxide query -i -- $argv)
    and __zoxide_cd $result
end

# =============================================================================
#
# Commands for zoxide. Disable these using --no-cmd.
#

abbr --erase z &>/dev/null
complete --command z --erase
function z
    __zoxide_z $argv
end
complete --command z --no-files --arguments '(__zoxide_z_complete)'

abbr --erase zi &>/dev/null
complete --command zi --erase
function zi
    __zoxide_zi $argv
end

# =============================================================================
#
# To initialize zoxide, add this to your configuration (usually
# ~/.config/fish/config.fish):
#
#   zoxide init fish | source
#
# Note: zoxide only supports fish v3.4.0 and above.
ajeetdsouza commented 1 year ago

@raguay is the directory you're trying to navigate to present in the database?

The way zoxide works is that you have to navigate to a directory normally once for zoxide to "learn" it, and then you can "jump" to it later. The GIF in the README has an example of this.

simplan-niklas commented 1 year ago

I have the same problem: image

The jump works, but the error is still presented.

simplan-niklas commented 1 year ago

Mhm, I've updated fish and opened a new shell. Now it works :) Fish Version 3.6.0.

ghuls commented 1 year ago

I have the same problem with bash when I have multiple terminal open. In that case it seems like no entries are added automatically to the database file.

ajeetdsouza commented 1 year ago

@ghuls can you create a separate issue with your zoxide / bash version? Issues like these are usually configuration errors, so it's easier to handle them separately.

github-actions[bot] commented 1 year ago

This issue has been automatically closed due to inactivity. If you feel this is still relevant, please comment here or create a fresh issue.