Closed catweazle9 closed 3 years ago
Thanks for giving so many details! I'll try to take a look into this later today.
I’m trying what you described, with
setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
both with my default setup, and after starting zsh
in plain vanilla mode (zsh -f
) and then sourcing ZSH-z, and I’m not seeing what you describe. I don’t see duplicates when I run dirs -v
, and pushdignoredups
is never disabled.
Could you post your whole .zshrc
, or provide a link to it? I’m sure that will allow me to see exactly what is going on. Thanks!
Never mind -- I shouldn't have responded so quickly. I can see what you mean, and I suspect that your analysis is quite correct. Let me see what I can do. It is possible that I can do something like replacing emulate -L zsh
with setopt NO_KSH_ARRAYS NO_SH_WORD_SPLIT
and get the effect I want.
Give the ZSH-z repo another pull and see if what I’ve done fixes your problem.
Yes, that fixes it - thanks very much. So it seems the problem was triggered by emulate -L zsh
. I wonder if that's a bug in zsh, or just a side-effect of using emulate -L zsh
. I'm not too clear on exactly what it's supposed to do! Hopefully the new code still works the same way:
setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT
I think what's going on is that emulate -L zsh
turns off PUSHD_IGNORE_DUPS
at the moment that cd
runs - but you'd figured that out yourself and deserve full credit. setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT
is a more specific way of addressing the fact that this code does not work when the KSH_ARRAYS
or SH_WORD_SPLIT
options are set. I may eventually rewrite each function to be inherently safe in those situations, but I think the code is easier to read the way it is right now.
I can’t seem to get tab completion working. I have this line in my database: 532.62 /c/users/johnc/Desktop
.. and was hoping I could type z esk<TAB>
to complete the above path.
Do I need any additional zsh variables to be set for this to work? I also tried first running zsh -f
to skip my startup files and then dot-sourcing zsh-z, but I have the same problem, ie zsh just does regular file completion.
I tried running compinit
and compinit -C
to regenerate my ~/.zcompdump file (I removed it first) but I don’t see any reference to zshz in that file.
Am I missing something?
Thanks,
--- John
From: Alexandros Kozák notifications@github.com Sent: 17 January 2021 19:25 To: agkozak/zsh-z zsh-z@noreply.github.com Cc: catweazle9 catweazle9@outlook.com; Author author@noreply.github.com Subject: Re: [agkozak/zsh-z] pushdignoredups is not respected - after using 'z' duplicates appear on the dirstack (#36)
I think what's going on is that emulate -L zsh turns off PUSHD_IGNORE_DUPS at the moment that cd runs - but you'd figured that out yourself and deserve full credit. setopt LOCAL_OPTIONS NO_KSH_ARRAYS NO_SH_WORD_SPLIT is a more specific way of addressing the fact that this code does not work when the KSH_ARRAYS or SH_WORD_SPLIT options are set. I may eventually rewrite each function to be inherently safe in those situations, but I think the code is easier to read the way it is right now.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agkozak/zsh-z/issues/36#issuecomment-761865671, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF4DNCKWC24KW4LRP3ZRDCDS2M2RXANCNFSM4WGHK4OA.
That should work. Do post your .zshrc
-- we'll save time that way.
If, after you
source /path/to/zsh-z.plugin.zsh
you run
autoload -U compinit && compinit
that should work. If you add
zstyle ':completion:*' menu select
the menus look amazing.
The completion also doesn’t work for me when I use zsh -f
, which skips running my .zshrc. I’m using zsh 5.5.1 on Cygwin – don’t know if that’s relevant?
I’ve attached my startup files anyway – they assume a Cygwin environment, e.g.,
export TERM=cygwin # Seems needed here for dircolors to work
eval /c/cygwin64/bin/dircolors -b ~/.console_colors.txt
These startup files all just live in my $HOME directory.
Thanks for any help,
--- John
From: Alexandros Kozák notifications@github.com Sent: 17 January 2021 23:05 To: agkozak/zsh-z zsh-z@noreply.github.com Cc: catweazle9 catweazle9@outlook.com; Author author@noreply.github.com Subject: Re: [agkozak/zsh-z] pushdignoredups is not respected - after using 'z' duplicates appear on the dirstack (#36)
If, after you
source /path/to/zsh-z.plugin.zsh
you run
autoload -U compinit && compinit
that should work. If you add
zstyle ':completion:*' menu select
the menus look amazing.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agkozak/zsh-z/issues/36#issuecomment-761896730, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF4DNCILCLKLS57YCRNJONTS2NUKRANCNFSM4WGHK4OA.
TERM linux TERM linux-c TERM mach-color TERM console TERM con132x25 TERM con132x30 TERM con132x43 TERM con132x60 TERM con80x25 TERM con80x28 TERM con80x30 TERM con80x43 TERM con80x50 TERM con80x60 TERM cygwin TERM dtterm TERM putty TERM xterm TERM xterm-color TERM xterm-debian TERM rxvt TERM screen TERM screen-bce TERM screen-w TERM vt100 TERM Eterm
NORMAL 1;00 # global default, although everything should be something. FILE 1;37 # normal file
DIR 1;36 # directory cyan EXEC 0 # Executables - uncolored, otherwise majority of files take on the built-in default color for executables LINK target OTHER_WRITABLE 1;31 # dir that is other-writable (o+w) and not sticky
.cmd 1;32 .exe 1;32 .dll 1;32 .com 1;32 .bat 1;32 .BAT 1;32 .ps1 1;32 .psm1 1;32
.java 1;33 .cs 1;33 .c 1;33 .cpp 1;33 .vbs 1;33 .sh 1;33 .el 1;33 .ahk 1;33 .pl 1;33 .jsp 1;33 .aspx 1;33 .asax 1;33 .js 1;33 .ts 1;33 .css 1;33 .scss 1;33 .tf 1;33 .tfvars 1;33 .yaml 1;33 .py 1;33
.class 1;33
.txt 1;31 .org 1;31 .doc 1;31 .dot 1;31 .docx 1;31 .xls 1;31 .xlsx 1;31 .pdf 1;31 .PDF 1;31 .ppt 1;31 .pptx 1;31 .rtf 1;31 .htm 1;31 .html 1;31 .json 1;31 .md 1;31
.cab 1;35 .tar 1;35 .tgz 1;35 .zip 1;35 .z 1;35 .Z 1;35 .gz 1;35 .bz2 1;35 .jar 1;35
.xml 1;35 .ini 1;35 .sln 1;35 .suo 1;35 .vssscc 1;35 .user 1;35 .vspscc 1;35 .scc 1;35 .proj 1;35 .csproj 1;35 .config 1;35
.jpg 1;33 .JPG 1;33 .jpeg 1;33 .gif 1;33 .bmp 1;33 .tif 1;33 .png 1;33 .PNG 1;33 .mov 1;33 .mpg 1;33 .avi 1;33 .svg 1;33 .ico 1;33
.targets 37 .conf 37 .pdb 37
Could you log in to
https://github.com/agkozak/zsh-z/issues/36
and copy and paste the contents of your .zshrc
there? GitHub doesn't really forward on file attachments -- I saw the contents of your dircolors
file, but nothing else.
By the way, I half wonder if there isn't something a little bit odd about your Cygwin setup. Usually Cygwin makes the C:
drive accessible at /cygdrive/c/
, not at /c/
(the latter is normal for MSYS2, which is derived from Cygwin). You may have mounted /cygdrive/c/
as /c/
for convenience, though. When I open Cygwin and type
cd /c
I get
cd: no such file or directory: /c
Yes, my /etc/fstab contains this content to mount the C drive under /c:
none / cygdrive binary,posix=0,user 0 0
I've attached my startup files. files.zip
OK, I’ve logged in to the issue URL and uploaded my startup files, hope that helps.
You’re right, I do configure my /etc/fstab to mount the C: drive on /c/ instead of /cygdrive/c, for convenience. I wouldn’t expect that would cause any completion problems?
How exactly does zsh-z hook into the zsh completion mechanism – wouldn’t I expect to see something related to zsh-z in .zcompdump?
--- John
From: Alexandros Kozák notifications@github.com Sent: 17 January 2021 23:54 To: agkozak/zsh-z zsh-z@noreply.github.com Cc: catweazle9 catweazle9@outlook.com; Author author@noreply.github.com Subject: Re: [agkozak/zsh-z] pushdignoredups is not respected - after using 'z' duplicates appear on the dirstack (#36)
Could you log in to
https://github.com/agkozak/zsh-z/issues/36
and copy and paste the contents of your .zshrc there? GitHub doesn't really forward on file attachments -- I saw the contents of your dircolors file, but nothing else.
By the way, I half wonder if there isn't something a little bit odd about your Cygwin setup. Usually Cygwin makes the C: drive accessible at /cygdrive/c/, not at /c/ (the latter is normal for MSYS2, which is derived from Cygwin). You may have mounted /cygdrive/c/ as /c/ for convenience, though. When I open Cygwin and type
cd /c
I get
cd: no such file or directory: /c
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agkozak/zsh-z/issues/36#issuecomment-761903104, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF4DNCIZ4VCLVMR7PJQWAITS2N2AVANCNFSM4WGHK4OA.
Well, to start with, you need to have the _zshz
file in the same directory as zsh-z.plugin.zsh
. It looks as if you keep the latter in your home (~
) directory. Is _zshz
there? That's the completion function itself.
And yes, in my .zcompdump
file, there's
'${ZSHZ_CMD:-${_Z_CMD:-z}}' '_zshz'
and
'zshz' '_zshz'
Both of those reference _zshz
-- make sure you've copied that file to the same directory as zsh-z.plugin.zsh
, or completion definitely won't happen.
Ah, yes, I was missing the _zshz file, apologies for that. I didn’t clone the repo, just copied the main file after assuming there was only one.
Anyway it’s working great now after re-running compinit -U && compinit
.
Do you interchange use of ‘z’ and ‘ls’? If I’m in a directory and want to browse to a (new) subdirectory with completion, presumably I need to still use ls
, since the completion for the new dir is not yet in z’s database?
--- John
From: Alexandros Kozák notifications@github.com Sent: 18 January 2021 00:32 To: agkozak/zsh-z zsh-z@noreply.github.com Cc: catweazle9 catweazle9@outlook.com; Author author@noreply.github.com Subject: Re: [agkozak/zsh-z] pushdignoredups is not respected - after using 'z' duplicates appear on the dirstack (#36)
And yes, in my .zcompdump file, there's
'${ZSHZ_CMD:-${_Z_CMD:-z}}' '_zshz'
and
'zshz' '_zshz'
Both of those reference _zshz -- make sure you've copied that file to the same directory as zsh-z.plugin.zsh, or completion definitely won't happen.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agkozak/zsh-z/issues/36#issuecomment-761909981, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF4DNCKENQP72YMWXBDX4TTS2N6Q5ANCNFSM4WGHK4OA.
Yes, I could see how you might end up switching back and forth between z
and ls
. In my case, I use z
a lot with directories where I known the structure very well -- since I go there all the time -- and I just don't want to have to type much of it.
I have the following options enabled (among others): autopushd pushdminus pushdsilent pushdtohome pushdignoredups
After using 'z', every time I visit a particular directory I see it duplicated on the dir stack (as shown by
dirs -v
). I seem to have worked around the problem by modifying zsh-z.plugin.zsh to add this line just after the zparseopts line: setopt pushdignoredupsI don't know exactly why the option is not being restored when the 'z' function terminates. I would have thought the LOCAL_OPTIONS should have taken care of it? Maybe the issue is that
emulate -L zsh
sets various default zsh options and pushdignoredups is not enabled by default, so when thecd
command runs, the dup gets added to the dir stack?Anyway I'm using ZSH_VERSION 5.5.1 under Cygwin on Windows. I don't use any of the 'package' systems such as oh-my-zsh or the like.