Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Shortcut Command To Watch A File For Changes

These are old notes.

I'm using watchexec now

I load this in my dotfiles to provide a `watch PATH`` command that prints out a file to the terminal every time it changes.

Code

function watch () {
    fswatch -event UPDATE -0 "$1" | xargs -0 -n1 cat
}
  • Update this so that if no argument is passed in it doesn't try to watch the entire system (or whatever it would do if there's no path)

  • link to the file that shows how to execute the file when it changes