bdben Posted December 4, 2022 Share Posted December 4, 2022 (edited) Hi all, I've been using zsh and oh-my-zsh for a few weeks now after following a few guides and everything seems to be working. Yesterday I discovered zsh-z and was excited to try it out. Well it works, except for tab completion. When I first started using it, tab did nothing at all, and now that I've used it a bit, pressing tab will populate the line with the highest ranked suggestion and show me a menu of other matching directories that I've visited, but it will not complete the names of directories in my current working directory. For example, with the following directory structure: . ├── foo │ └── bar ├── bar └── some └── other └── directory └── containing └── bar If my working directory is /foo and I type "z b <tab>" then I might get the suggestion z /some/other/directory/containing/bar if that's the only matching directory I've ever visited using z. I don't think this is the intended behavior, though I could be wrong. I know it shouldn't be exactly like cd, because that's the whole point, but if I have to manually type in every directory I visit until I've gone through my entire filesystem then that sort of defeats the purpose of this tool. The github repo specifically mentions running "autoload -U compinit && compinit" to get tab completion working, however compinit is already run by oh-my-zsh after loading plugins. Nevertheless I tried adding it explicitly to my .zshrc, but not surprisingly it had no effect on tab completion. One clue is that I have the zsh-syntax-highlighting plugin, and the "z" in the command above does not get colored as a command but rather remains white. I suspect this is related, since tab completion works everywhere else that I'd expect it to. Here is my .zshrc file: export ZSH="/root/.oh-my-zsh" ZSH_THEME="robbyrussell" DISABLE_UPDATE_PROMPT="true" HISTSIZE=10000 SAVEHIST=10000 HISTFILE=/root/.cache/zsh/history plugins=( zsh-autosuggestions zsh-syntax-highlighting docker z ) source $ZSH/oh-my-zsh.sh # User configurations alias l='ls -lFh' #size,show type,human readable alias la='ls -lAFh' #long list,show almost all,show type,human readable alias drst='docker restart' # Completion style for zsh-z zstyle ':completion:*' menu select # Set zsh-autosuggestion configuration: ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion) I have zsh installed from the NerdTools plugin, and the following script executes at first startup of array: #!/bin/bash HOME=/root OH_MY_ZSH_ROOT="$HOME/.oh-my-zsh" ZSH_CUSTOM="$HOME/.oh-my-zsh/custom" OH_MY_ZSH_PLUGINS="$ZSH_CUSTOM/plugins" OH_MY_ZSH_THEMES="$ZSH_CUSTOM/themes" mkdir -p $OH_MY_ZSH_PLUGINS mkdir -p $OH_MY_ZSH_THEMES # Install zsh-autosuggestions if [ ! -d "$OH_MY_ZSH_PLUGINS/zsh-autosuggestions" ]; then echo " -> Installing zsh-autosuggestions..." git clone https://github.com/zsh-users/zsh-autosuggestions $OH_MY_ZSH_PLUGINS/zsh-autosuggestions else echo " -> zsh-autosuggestions already installed" fi # Install zsh-syntax-highlighting if [ ! -d "$OH_MY_ZSH_PLUGINS/zsh-syntax-highlighting" ]; then echo " -> Installing zsh-syntax-highlighting..." git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $OH_MY_ZSH_PLUGINS/zsh-syntax-highlighting else echo " -> zsh-syntax-highlighting already installed" fi chsh -s /bin/zsh # Remove oh-my-zsh default .zshrc and zsh-z default .z rm /root/.zshrc rm /root/.z # Make sure the necessary directories are existing mkdir -p /root/.cache/zsh/ mkdir -p /boot/config/extra/ # Make sure history file exists touch /boot/config/extra/history # Symlink .zshrc and history files cp -sf /boot/config/extra/.zshrc /root/.zshrc cp -sf /boot/config/extra/history /root/.cache/zsh/history cp -sf /boot/config/extra/.z /root/.z # Tracks "frecency" of directories for zsh-z, so needs to be persisten chmod 755 $OH_MY_ZSH_PLUGINS/zsh-autosuggestions chmod 755 $OH_MY_ZSH_PLUGINS/zsh-syntax-highlighting chmod 755 $OH_MY_ZSH_ROOT/cache/completions Can anyone see what's wrong with this configuration? Edited December 4, 2022 by bdben Added context of working directory to example Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.