Inotify, Run (Python) script once it changes

This is sadly Linux Only, start by installing inotify-tools:

# apt-get install inotify-tools

and create the following script:

echo Waiting for filechange ...
inotifywait -q -m -e close_write,moved_to --format %e/%f . |
while IFS=/ read -r events file; do
    if [ "$file" = "" ]; then
        python ./

this actually watches the directory, because Vim writes files by writing your alterations to a temporary file and moving it in place of the old one, however this aproach also works with normal write.

Dette indlæg blev udgivet i Linux, Vim. Bogmærk permalinket.

Skriv et svar