diff --git a/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md b/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md index 348f1eba2ff..2977a51e1af 100644 --- a/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md +++ b/assets/chezmoi.io/docs/user-guide/use-scripts-to-perform-actions.md @@ -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 diff --git a/internal/cmd/testdata/scripts/issue3421.txtar b/internal/cmd/testdata/scripts/issue3421.txtar new file mode 100644 index 00000000000..a650148bae3 --- /dev/null +++ b/internal/cmd/testdata/scripts/issue3421.txtar @@ -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