marlonrichert / zsh-autocomplete

🤖 Real-time type-ahead completion for Zsh. Asynchronous find-as-you-type autocompletion.
MIT License
5.38k stars 148 forks source link

recent-directories stopped working #643

Closed ad-on-is closed 1 year ago

ad-on-is commented 1 year ago
+autocomplete:recent-directories() {
  reply=(${(f)"$(zoxide query -l)"})
}

I had this code in my .zshrc file for recent directories. This stopped working. Were there any breaking changes introduced recently?

ad-on-is commented 1 year ago

Sorry to bother, but this was an issue with zoxide. https://github.com/aymanbagabas/dotfiles/commit/30e8323147281b07a9f77879b6d14881acbf0ff4

stefan2904 commented 11 months ago

maybe-stupid question, why reply=(${(f)"$(zoxide query -l)"}) and not typeset -ga reply=(zoxide query -l) like in the README?

ad-on-is commented 11 months ago

@stefan2904 I just followed a guide that I found online a few years ago.

marlonrichert commented 10 months ago

typeset -ga reply=(zoxide query -l) does not work correctly. Just try it on the command line:

% typeset -ga reply=(zoxide query -l); typeset -p1 reply
typeset -a reply=(
  zoxide
  query
  -l
)
%

reply=( ${(f)"$( zoxide query -l )"} ) is the correct way to do it:

ad-on-is commented 10 months ago

typeset -ga reply=(zoxide query -l) does not work correctly. Just try it on the command line:

% typeset -ga reply=(zoxide query -l); typeset -p1 reply
typeset -a reply=(
  zoxide
  query
  -l
)
%

reply=( ${(f)"$( zoxide query -l )"} ) is the correct way to do it:

* `"$( <command> )"` preserves all whitespace in `<command>`'s output.

* `${(f)"$( <command> )"}` splits the output on newlines.

That's how I have it, but strangely it doesn't work in the users home-directory.

If, in the home-directory I type cd foo, I'd expect it to show all recent directories containing foo, but it does not. Doing a zoxide query -l foohowever brings up a few results.

If I cd into ~/Downloads and do the same, the results come up.

marlonrichert commented 5 months ago

@ad-on-is And is that a problem in Autocomplete or in Zoxide?