Automatically revert buffers

If you want Emacs to automatically update a buffer if a file changes on disk, then add the following to your emacs config file

;; auto revert mode
(global-auto-revert-mode 1)

Of course, if your buffer has unsaved changes when the file changes on disk, then Emacs will prompt you and your changes won’t be lost.

This mode only applies to buffers associated with files on the disk, but I like to have my dired view updated if the contents of a directory change. This is accomplished with the following code:

;; auto refresh dired when file changes
(add-hook 'dired-mode-hook 'auto-revert-mode)