event - manage named shell event hook registrations.
event add event name function [--priority number] event add timer.tick name function --every milliseconds [--priority number] event remove event name event list [--json] [event]
event registers shell functions for Rush shell events. Registrations are named. Reusing an event and name replaces that hook.
Hooks run by ascending priority, then registration name. The default priority is zero. Hooks preserve visible status unless they exit the shell.
event list prints hooks grouped by event. event list --json prints objects with event, name, function, priority, and optional every_ms.
directory.change direnv priority=0 rush_direnv_hook timer.tick clock priority=0 every=1000ms on_clock
Hooks receive temporary RUSH_EVENT and RUSH_EVENT_HOOK assignment-prefix variables while they run.
directory.change$1 and new directory as $2. Also runs once at interactive startup before the first prompt, with an empty $1 and the initial directory as $2.prompt.prepareprompt.async.start, prompt.async.endprompt async refresh work starts or ends. Receive $1=prompt and $2 as the active count.job.start, job.end$1=job and $2 as the active job count.timer.tick--every interval. Receives the registration name as $1.sync_project_env() { if test -f .envrc; then . ./.envrc fi } remember_prompt_cwd() { rush_prompt_cwd="$PWD" } event add directory.change project-env sync_project_env --priority -10 event add prompt.prepare prompt-cwd remember_prompt_cwd event add timer.tick clock remember_prompt_cwd --every 1000
Enable bundled project-environment helpers in a later config file. These helper functions are autoloaded from share/rush/functions when the hook first runs:
event add directory.change direnv rush_direnv_hook event add directory.change mise rush_mise_hook
Replace or remove hooks by event/name:
event add directory.change direnv my_direnv_hook event remove directory.change mise
Zero on success and two for usage errors.