The watch.el package repeatedly runs a command, displaying the output in an Emacs buffer. Unlike the Unix watch command, it offers additional features:

  1. Pause, resume, and immediately refresh the output.
  2. Updates are temporarily paused while selecting text.
  3. Adjust the refresh interval without restarting.
  4. Supports ANSI escape sequences.

Installation

Use Package VC

projects/watch-el/index.md:26:```elisp
projects/watch-el/index.md:32:```elisp
projects/watch-el/index.md:39:```elisp
projects/watch-el/index.md:74:```elisp
(use-package watch
  :vc (:url "https://github.com/Stebalien/watch.el"))

Elpaca

Directly:

(elpaca (watch :host github :repo "Stebalien/watch.el"))

Or with use-package:

(use-package
  :ensure (watch :host github :repo "Stebalien/watch.el"))

Straight

(use-package watch
  :straight (watch :type git :host github :repo "Stebalien/watch.el"))

Usage

M-x watch RET <command> RET

You’ll be prompted for a command to watch and an interval between updates (default: 2 seconds).

Key Bindings

In a watch buffer:

KeyDescription
qQuit the watch buffer
gRefresh immediately
iChange the update interval
pToggle pause/resume

Status Indicators

The header line shows the current status of the watch buffer:

  • <P> - Paused
  • <R> - Running (command is executing)
  • <S> - Sleeping (between command runs)
  • <!> - Failed (command exited with non-zero status)

Customization

You can customize the various status indicators:

(setopt watch-paused-indicator "[PAUSED]"
        watch-running-indicator "[RUNNING]"
        watch-sleeping-indicator "[SLEEPING]"
        watch-failed-indicator "[FAILED]")

For a complete list of options, run M-x customize-group RET watch RET.