zsh-autocomplete
zsh-autocomplete copied to clipboard
recent-dirs autocomplete with default settings (cdr) not working out-of-the-box as expected
Environment
apple darwin21.0 /bin/zsh -zsh zsh-5.8-0-g77d203f
/Users/ecereto/src/znap/zsh-snap/functions/.znap.source:26
/Users/ecereto/src/znap/zsh-snap/functions/znap:42
/Users/ecereto/.zshrc:18
d6a0ff5 (grafted, HEAD -> main, origin/main, origin/HEAD) Fix a bug in async list trimming
- Operating system: macOS
- Terminal emulator: iTerm2
Steps to reproduce
cd $(mktemp -d)
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
> .zshrc <<EOF
PS1='%# ' PS2= RPS2='%^'; setopt transientrprompt interactivecomments
source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
mkdir -p test1/test2/test3/test4
mkdir -p bla/bla/bla
cd test1/test2/test3
cd ../../../
cd bla/bla/bla
cd ../../../
cd # Wait for autocomplete but recent dirs doesn't show up
> directory
> bla/ test1/ zsh-autocomplete/
cdr
> zsh: command not found: cdr
Should I enable cdr manually? Found very confusing setup instructions and don't want to go down this rabbit hole. I could try to use something else but I'm asking just because the docs say it should work automatically.
Local dirs get priority over recent ones and you need to type at least part of the recent dir you're looking for. For example:
% cd $(mktemp -d)
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
Cloning into 'zsh-autocomplete'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 59 (delta 0), reused 24 (delta 0), pack-reused 0
Receiving objects: 100% (59/59), 1.64 MiB | 1.56 MiB/s, done.
% > .zshrc <<EOF
PS1='%# ' PS2= RPS2='%^'; setopt transientrprompt interactivecomments
source ~/zsh-autocomplete/zsh-autocomplete.plugin.zsh
EOF
% env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
% mkdir -p test1/test2/test3/test4
% mkdir -p bla/bla/bla
% cd test1/test2/test3
% cd ../../../
% cd bla/bla/bla
% cd ../../../
% cd test1
% cd b
recent directory
~/bla/bla/bla
Should I enable cdr manually?
Yes, add this to your .zshrc
file:
autoload -Uz cdr
the docs say it should work automatically.
The docs say that it uses cdr
under the hood by default to complete recent dirs. However, it does not say that it automatically makes the cdr
function available on the command line.