twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
13.32k stars 493 forks source link

Script to run always part of chezmoi status and chezmoi diff #1910

Closed tnek213 closed 2 years ago

tnek213 commented 2 years ago

Describe the bug

An added run-script is always part of chezmoi status and chezmoi diff.

For status I see:

❯ chezmoi --verbose status
 R scripted_configuration.sh

For diff I see: (the whole script with plus in front of every line)

❯ chezmoi --verbose diff
diff --git a/scripted_configuration.sh b/scripted_configuration.sh
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..552c68527d10f0c1014c62b065563fcd7a542de2 100755
--- a/scripted_configuration.sh
+++ b/scripted_configuration.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+has() {
+  command -v "$1" &>/dev/null
+}
+
+has jq || exit
+
+chezDir="$HOME/.config/chezmoi"
...

To reproduce

Steps to reproduce the behavior.

I guess clone my dotfiles repo https://github.com/tnek213/dotfiles . I see the same behavior on two different machines. Both running arch.

Expected behavior

A clear and concise description of what you expected to happen.

Output of command with the --verbose flag

Maybe it should be part of chezmoi status to indicate that a script will be ran on chezmoi apply. But that the whole script is in the diff, that i weird and seems like a bug.

Output of chezmoi doctor

```console ❯ chezmoi doctor RESULT CHECK MESSAGE warning version v2.12.0, built at 2022-02-15T11:45:02Z ok os-arch linux/amd64 (Arch Linux) ok uname Linux klll 5.16.10-arch1-1 #1 SMP PREEMPT Wed, 16 Feb 2022 19:35:18 +0000 x86_64 GNU/Linux ok go-version go1.17.7 (gc) ok executable /usr/bin/chezmoi ok config-file ~/.config/chezmoi/chezmoi.json ok source-dir ~/.local/share/chezmoi is a directory ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a directory ok dest-dir ~ is a directory ok shell found /bin/bash ok edit-command found /usr/bin/nano ok umask 022 ok git-command found /usr/bin/git, version 2.35.1 ok merge-command found /usr/bin/vimdiff info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.2.32 info pinentry-command not set info 1password-command op not found in $PATH ok bitwarden-command found ~/.nvm/versions/node/v12.22.10/bin/bw, version 1.21.1 info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keepassxc-db not set info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info vault-command vault not found in $PATH info secret-command not set ```

Additional context

After chezmoi cd my working tree is clean and git status returns nothing to commit.

twpayne commented 2 years ago

See https://www.chezmoi.io/user-guide/tools/diff/#dont-show-scripts-in-the-diff-output.

twpayne commented 2 years ago

Thanks for reporting this, I added 843ba3344e97386d5a5367d599e69e6a875553dc to improve chezmoi's documentation.

kentlarsson commented 2 years ago

Thanks for a great tool! <3