I am trying to automate running any Python file in a directory when the file is saved. That way, the doctests will run, and I don't have to switch away from the editor.

My problem is that whenever I save a .py file, it runs twice.

Here's my command:

ls *.py | entr -p python /_

The -p is to postpone until the file is saved, and that works fine.

  • What editor do you use?
    – user1686
    Apr 20, 2020 at 14:47
  • @user1686 I use vim.
    – hstr
    Apr 20, 2020 at 14:49

1 Answer 1


The issue stems from how vim writes files in two stages by default. When inotify (which entr is based on) sees these events they're interpreted as two saves.

On my machine, this fixes the issue:

:set backupcopy=yes

You can add that to your .vimrc to make it permanent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.