Use the --ignore-patterns
(-i
) switch.
watchmedo shell-command \
-p'*.py' \
-R \
-c'echo "${watch_src_path}"'\
--ignore-patterns="*/.*"
Note that watchmedo is matching on the full watch_src_path so your ignore pattern can't be as simple as ".*"
like you'd think at first. Also all the pitfalls of wildcards are in effect, so if you were doing something silly like working in a hidden directory /path/to/some/.hidden/dir
then you'd have to have a fancier pattern.
You also might want the --ignore-directories
(-D
) switch if the directory-related event is causing you annoyance too (this one is just boolean, no argument needed).