Skip to content

Instantly share code, notes, and snippets.

@jarnaldich
Created February 6, 2019 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarnaldich/edb73c7f0604a6e1de7f7b7cb1b8031a to your computer and use it in GitHub Desktop.
Save jarnaldich/edb73c7f0604a6e1de7f7b7cb1b8031a to your computer and use it in GitHub Desktop.
Powershell File System Watcher #powershell #watch #filesystem
$w = New-Object System.IO.FileSystemWatcher
$w.Path= pwd
$w.Filter= "*.py"
$w.EnableRaisingEvents = $true
$action = { (&{ cls; $p = $Event.SourceEventArgs.FullPath; python $p }) 2>&1 | Write-Host }
$changed = Register-ObjectEvent $w "Changed" -Action $action
Unregister-Event $changed.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment