jeffreytse / zsh-vi-mode

💻 A better and friendly vi(vim) mode plugin for ZSH.
MIT License
3.13k stars 109 forks source link

Command edition in Editor not working on MacOS if noclobber option is set #129

Closed Mrngilles closed 2 years ago

Mrngilles commented 2 years ago

I've been trying to understand exactly why my edition in editor was not working anymore on mac, and after investigation, I did find out that since I have the option noclobber in my rcfile, the following line was actually trying to override an existing file:

https://github.com/jeffreytse/zsh-vi-mode/blob/63e5a5209b238771e528dd22d2ac1a317ace7319/zsh-vi-mode.zsh#L1751

I think this behaviour is Mac specific, and that there might be some strange behaviour happening with mktemp reusing files, even though you delete it.

I got it working by creating a custom widget, and simply replacing

  echo "$BUFFER" > "$tmp_file"

with

  echo "$BUFFER" >! "$tmp_file"

This solution should work no matter the status of the clobber option.

Hopefully that is clear enough a description. Please let me know if you need more information

jeffreytse commented 2 years ago

Hi @Mrngilles

Thanks for your issue, it's useful, and I will take a look as soon as possible. : )

Thanks and Regards

jeffreytse commented 2 years ago

Hi @Mrngilles

Thanks for your useful information, and now this issue has been fixed. You can update your plugin to the latest version. Hope you have a good day! : )

Thanks and Regards

Mrngilles commented 2 years ago

works, thanks a lot