Open paulmist opened 6 months ago
I might have the same problem. It's my first time using this plugin and tab completion only shows options, not directories
Try typing
which _z | less
and give me the first few lines of what it says. Thanks!
Let me know if you need more. Thanks!
_z () {
local datafile="${_Z_DATA:-$HOME/.z}"
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
if [ "$1" = "--add" ]
then
It looks as if you're not actually using Zsh-z, but rather rupa/z
, which was the original z
utility that shipped with Oh-My-Zsh. Oh-My-Zsh has been using Zsh-z since 2022. rupa/z
doesn't seem to work with recent versions of Zsh, for some reason.
You'll want to upgrade your Oh-My-Zsh installation. Back up your $ZSH
directory, if you want to. Then use
omz update
You might also want to
exec zsh
Then try using z
with tab completion. If you want to check to be sure that the upgrade has been successful, you can use
which _z | less
again. The code returned should look like
_z () {
emulate -L zsh
(( ZSHZ_DEBUG )) && setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
local completions expl completion
local -a completion_list
completions=$(zshz --complete ${(@)words:1})
[[ -z $completions ]] && return 1
for completion in ${(f)completions[@]}
etc.
Let me know if that worked.
Thanks for your help.
I tried all of the above - but nothing worked. OMZ was already up-to-date.
However, I then found this line in my .zshrc file…
. `brew --prefix`/etc/profile.d/z.sh
Which I believe I added one time when z stopped working altogether.
I've removed that line, and all is working again.
@paulmist I can't believe I missed that line! Glad you've got it fixed.
@gBonvenuto Want to check if you've got something similar going on? Try which _z | less
and see what code comes up.
Hello, thank you for mentioning me!
here's my which _z | less
first lines:
_z () {
local datafile="${_Z_DATA:-$HOME/.z}"
[ -h "$datafile" ] && datafile=$(readlink "$datafile")
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
_z_dirs () {
local line
while read line
do
[ -d "${line%%\|*}" ] && echo "$line"
done < "$datafile"
return 0
}
if [ "$1" = "--add" ]
then
I tried the steps of update omz, and it's still the same output
EDIT: seems like I'm also using rupa, because in my .oh-my-zsh/plugins/z/z.sh this is the first line:
# Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2
I think it might be worth mentioning I used to use zoxide before knowing there was this zsh plugin
EDIT 2: I've decided to just install it with git clone in my custom/plugins directory. Sorry for this roller-coaster lol
I'm having a similar issue. z [TAB]
completes child directories from my CWD.
Typing which _z | less
yields _z not found
. I can verify that the _zshz
file exists under the plugin and I have autoload -Uz compinit && compinit;
called at the top of my .zshrc
file.
@Nxt3 I'll try to help you. Please post the contents of your .zshrc
file -- that will save me time.
@agkozak Sure thing:
#!/opt/homebrew/bin zsh
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.bash/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# load autocompletion
autoload -Uz compinit && compinit;
# +---------+
# | PLUGINS |
# +---------+
# get zsh_unplugged and store it with plugins
if [[ ! -d $ZPLUGINDIR/zsh_unplugged ]]; then
git clone --quiet https://github.com/mattmc3/zsh_unplugged $ZPLUGINDIR/zsh_unplugged
fi
source $ZPLUGINDIR/zsh_unplugged/zsh_unplugged.zsh
# plugin repos
repos=(
romkatv/powerlevel10k
tarrasch/zsh-bd
agkozak/zsh-z
laggardkernel/zsh-thefuck
zsh-users/zsh-autosuggestions
zsh-users/zsh-syntax-highlighting
)
plugin-load $repos
# +------------+
# | PATH STUFF |
# +------------+
# load homebrew in PATH
export PATH="/opt/homebrew/bin:$PATH"
# +--------------+
# | MISC OPTIONS |
# +--------------+
export CLICOLOR=1 # color directories when running 'ls'
setopt CORRECT # Spelling correction
# smart-casing for z-command
ZSHZ_CASE=smart
# +---------+
# | HISTORY |
# +---------+
export HISTFILE="$HOME/.zhistory"
setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file.
setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again.
setopt SHARE_HISTORY # Share history between all sessions.
# +----------------+
# | CUSTOMIZATIONS |
# +----------------+
for file in ~/.bash/zsh/customizations/*; do
if [[ -f $file ]]; then
source "$file"
fi;
done
# case-insensitive auto-completion
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
# better looking completions for z-command
zstyle ':completion:*' menu select
@Nxt3 OK, I found the problem. You need to autoload -U compinit; compinit
after you've loaded the Zsh-z plugin. If you move that line down below
plugin-load $repos
I think everything should work.
Nice okay that fixes z
's autocomplete but it breaks completion for the other plugins that are loaded: compdef not found
.
Seems like I need to figure out the load order.
Thanks for the help!
I've been using the Z plugin with Oh My Zsh for years and suddenly the tab suggestions have disappeared.
Thanks in advance.
Here's my .zshrc file if that's of use: