github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/events/onfilesystemchange.md (about) 1 # `onFileSystemChange` 2 3 > Add a filesystem watch 4 5 ## Description 6 7 `onFileSystemChange` events are triggered whenever there is a change to a 8 watched path or file. 9 10 ## Usage 11 12 ``` 13 event onFileSystemChange name=path { code block } 14 15 !event onFileSystemChange name 16 ``` 17 18 ## Valid Interrupts 19 20 * `<path>` 21 Path of directory or file to watch for filesystem events 22 23 ## Payload 24 25 The following payload is passed to the function via STDIN: 26 27 ``` 28 { 29 "Name": "", 30 "Interrupt": { 31 "Path": "", 32 "Operation": "" 33 } 34 } 35 ``` 36 37 ### Name 38 39 This is the name you specified when defining the event 40 41 ### Path 42 43 The path of the file that has triggered the event 44 45 ### Operation 46 47 This is the filesystem operation that triggered the event. The following 48 strings could be present in the **Operation** field: 49 50 * `create`: filesystem object created 51 * `remove`: filesystem object deleted 52 * `write`: filesystem object has been written to 53 * `rename`: filesystem object has been renamed 54 * `chmod`: filesystem object has had its POSIX permissions updated 55 56 Sometimes you might see more than one operation per interrupt. If that happens 57 the operation will be pipe delimited. For example `create|chmod` 58 59 ## Examples 60 61 This will automatically add any new files in your current working directory to 62 git upon file creation: 63 64 ``` 65 event onFileSystemChange example=. { 66 -> set event 67 if { $event.Interrupt.Operation =~ "create" } then { 68 git add $event.Interrupt.Path 69 } 70 } 71 ``` 72 73 ## Detail 74 75 ### Stdout 76 77 Stdout is written to the terminal. 78 79 ### POSIX only 80 81 At this stage, this event isn't available for Windows nor Plan 9. This is 82 chiefly down to a lack of testers on either platform so rather than release 83 untested and potentially broken code, the decision was made to restrict this 84 event to Linux, macOS and UNIX systems instead. 85 86 ## See Also 87 88 * [`config`](../commands/config.md): 89 Query or define Murex runtime settings 90 * [`event`](../commands/event.md): 91 Event driven programming for shell scripts 92 93 <hr/> 94 95 This document was generated from [builtins/events/onFileSystemChange/onfilesystemchange_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/events/onFileSystemChange/onfilesystemchange_doc.yaml).