Skip to content

Commit

Permalink
docs: Fix guide on clearing state of run_onchange_ scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Dec 21, 2023
1 parent 7323f6a commit 08e9b0b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ does not create `dconf.ini` in your home directory.
## Clear the state of all `run_onchange_` and `run_once_` scripts

chezmoi stores whether and when `run_onchange_` and `run_once_` scripts have
been run in the `scriptState` bucket of its persistent state. To clear the state, run:
been run in its persistent state.

To clear the state of `run_onchange_` scripts, run:

```console
$ chezmoi state delete-bucket --bucket=entryState
```

To clear the state of `run_once_` scripts, run:

```console
$ chezmoi state delete-bucket --bucket=scriptState
Expand Down
29 changes: 29 additions & 0 deletions internal/cmd/testdata/scripts/issue3421.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[windows] skip 'UNIX only'

# test that chezmoi runs run_once_ and run_onchange_ scripts only once
exec chezmoi apply
stdout once
stdout onchange
exec chezmoi apply
! stdout .

# test that chezmoi runs run_once_ scripts after chezmoi state delete-bucket --bucket=scriptState
exec chezmoi state delete-bucket --bucket=scriptState
exec chezmoi apply
stdout once
! stdout onchange

# test that chezmoi runs run_once_ scripts after chezmoi state delete-bucket --bucket=entryState
exec chezmoi state delete-bucket --bucket=entryState
exec chezmoi apply
! stdout once
stdout onchange

-- home/user/.local/share/chezmoi/run_once_once.sh --
#!/bin/sh

echo once
-- home/user/.local/share/chezmoi/run_onchange_onchange.sh --
#!/bin/sh

echo onchange

0 comments on commit 08e9b0b

Please sign in to comment.