Repository: twpayne/chezmoi
Pull request #178 (2019-01-28 05:50:41)

Miscellaneous clean-ups


Patch:
diff --git a/README.md b/README.md
index f825592eb..ce78c35ff 100644
--- a/README.md
+++ b/README.md
@@ -124,18 +124,23 @@ the destination directory, where:
  * The *config file* contains machine-specific configuration, by default it is
    `~/.config/chezmoi/chezmoi.yaml`.
 
+Initialize `chezmoi`:
+
+    $ chezmoi init
+
+This will create a new `git` repository in `~/.local/share/chezmoi` with
+permissions `0700` where `chezmoi` will store the source state.  `chezmoi`
+generally only modifies files in the working copy. It is your responsibility to
+commit changes.
+
+`chezmoi` works with many other version control systems too. See "Using non-git
+version control systems" below if you don't want to use `git`.
+
 Manage an existing file with `chezmoi`:
 
     $ chezmoi add ~/.bashrc
 
-This will create the source directory `~/.local/share/chezmoi` with permissions
-`0600` where `chezmoi` will store the source state (if it does not already
-exist), and copy `~/.bashrc` to `~/.local/share/chezmoi/dot_bashrc`.
-
-You should manage your `~/.local/share/chezmoi` directory with the version
-control system of your choice. `chezmoi` will ignore all files and directories
-beginning with a `.` in this directory, including directories like `.git` and
-`.hg`.
+This will copy `~/.bashrc` to `~/.local/share/chezmoi/dot_bashrc`.
 
 Edit the source state:
 
@@ -157,20 +162,56 @@ changes they will make to the file system, and the `-n` (dry run) flag to not
 make any actual changes. The combination `-n` `-v` is very useful if you want
 to see exactly what changes would be made.
 
+Finally, change to the source directory, commit your changes, and return to
+where you were:
+
+    $ chezmoi cd
+    $ git add dot_bashrc
+    $ git commit -m "Updated .bashrc"
+    $ exit
+
 For a full list of commands run:
 
     $ chezmoi help
 
-## Setting up from existing source
 
-If you put your source directory under version control you will eventually want
-to check it out on another host. `chezmoi` can do this for you and make sure all
-directory permissions are setup correctly:
+## Using a hosted repo to manage your dotfiles across multiple machines
+
+`chezmoi` relies on your version control system and hosted repo to share
+changes across multiple machines. You should create a repo on the source code
+repository of your choice (e.g. [Bitbucket](https://bitbucket.org),
+[Github](https://github.com/), or [GitLab](https://gitlab.com), many people
+call their repo `dotfiles`) and push the repo in the source directory here. For
+example:
+
+    $ chezmoi cd
+    $ git remote add origin https://github.com/username/dotfiles.git
+    $ git push -u origin master
+    $ exit
+
+On another machine you can checkout this repo:
+
+    $ chezmoi init https://github.com/username/dotfiles.git
+
+You can then see what would be changed:
+
+    $ chezmoi diff
+
+If you're happy with the changes then apply them:
+
+    $ chezmoi apply
+
+The above commands can be combined into a single init, checkout, and apply:
+
+    $ chezmoi init --apply --verbose https://github.com/username/dotfiles.git
+
+You can pull the changes from your repo and apply them in a single command:
+
+    $ chezmoi update
+
+This runs `git pull --rebase` in your source directory and then `chezmoi
+apply`.
 
-    $ chezmoi init git@github.com:example/dotfiles.git
-    
-Like all other commands, `chezmoi init` also accepts the `-v` (verbose) and `-n`
-(dry run) flag. 
 
 ## Using templates to manage files that vary from machine to machine
 
@@ -467,74 +508,6 @@ You can encrypt your configuration and then only decrypt it when needed:
     $ gpg -d ~/.config/chezmoi/chezmoi.yaml.gpg | chezmoi -c /dev/stdin apply
 
 
-## Managing your source directory with version control
-
-`chezmoi` has some helper commands to assist managing your source directory
-with version control. The default version control system is `git` but you can
-change this by setting `sourceVCS.command` in your
-`~/.config/chezmoi/chezmoi.yaml` file, for example, if you want to use
-Mercurial:
-
-    sourceVCS:
-      command: hg
-
-`chezmoi source` is then a shortcut to running `sourceVCS.command` in your
-`~/.local/share/chezmoi` directory. For example you can push the current branch
-with:
-
-    $ chezmoi source push
-
-Extra arguments are passed along unchanged, although you'll need to use `--`
-stop `chezmoi` from interpreting extra flags. For example:
-
-    $ chezmoi source pull -- --rebase
-
-The `source` command accepts the usual `-n` and `-v` flags, so you can see
-exactly what it will run without executing it.
-
-As a shortcut,
-
-    $ chezmoi cd
-
-starts a shell in your source directory, which can be very useful when
-performing multiple VCS operations.
-
-### Setting Up the Initial VC Repo
-
-Currently, this document only covers the GIT VC system.
-
-#### GIT
-
-If you are installing `chezmoi` for the first time, and do not yet have a git repo setup for your chezmoi controlled dotfiles, the process is outlined below.
-
-Open a shell within your chezmoi source directory.
-
-    $ chezmoi cd
-
-Initialize a git repository.
-
-    $ chezmoi source init
-
-Add any files that you have previously started managing with chezmoi.
-
-    $ git add .
-
-Commit the files into the local git repository.
-
-    $ git commit
-
-##### Optional Steps - Adding to an existing GitHub Repo
-
-Create a new GitHub repo as you normally would within the GitHub interface.
-
-Add the remote source.
-
-    $ git remote add origin <repository url>
-
-*Note* - Depending on what data you have in the remote URL, you may have to fix things up with something like `git branch --set-upstream-to=origin/master master` and then push with something like `git push --set-upstream origin master`.
-
-Exit out of the chezmoi shell with either `exit`, or `Ctrl - D`
-
 ## Importing archives
 
 It is occasionally useful to import entire archives of configuration into your
@@ -564,6 +537,21 @@ target state. A particularly useful command is:
 which lists all the targets in the target state.
 
 
+## Using non-`git` version control systems
+
+By default, `chezmoi` uses `git`, but you can use any version control system of
+your choice. In your config file, specify the command to use. For example, to
+use Mercurial specify:
+
+    sourceVCS:
+      command: hg
+
+The source VCS command is used in the `chezmoi` commands `init`, `source`, and
+`update`, and support for VCSes other than `git` is limited but easy to add. If
+you'd like to see your VCS better supported, please [open an issue on
+Github](https://github.com/twpayne/chezmoi/issues/new).
+
+
 ## Under the hood
 
 For an example of how `chezmoi` stores its state, see
diff --git a/cmd/add.go b/cmd/add.go
index 5a82ff056..ae10ba6c7 100644
--- a/cmd/add.go
+++ b/cmd/add.go
@@ -11,23 +11,23 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var addCommand = &cobra.Command{
+var addCmd = &cobra.Command{
 	Use:   "add targets...",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Add an existing file, directory, or symlink to the source state",
-	RunE:  makeRunE(config.runAddCommand),
+	RunE:  makeRunE(config.runAddCmd),
 }
 
-type addCommandConfig struct {
+type addCmdConfig struct {
 	recursive bool
 	prompt    bool
 	options   chezmoi.AddOptions
 }
 
 func init() {
-	rootCommand.AddCommand(addCommand)
+	rootCmd.AddCommand(addCmd)
 
-	persistentFlags := addCommand.PersistentFlags()
+	persistentFlags := addCmd.PersistentFlags()
 	persistentFlags.BoolVarP(&config.add.options.Empty, "empty", "e", false, "add empty files")
 	persistentFlags.BoolVarP(&config.add.options.Exact, "exact", "x", false, "add directories exactly")
 	persistentFlags.BoolVarP(&config.add.prompt, "prompt", "p", false, "prompt before adding")
@@ -35,7 +35,7 @@ func init() {
 	persistentFlags.BoolVarP(&config.add.options.Template, "template", "T", false, "add files as templates")
 }
 
-func (c *Config) runAddCommand(fs vfs.FS, args []string) (err error) {
+func (c *Config) runAddCmd(fs vfs.FS, args []string) (err error) {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/apply.go b/cmd/apply.go
index 39eb5a78e..5171638ec 100644
--- a/cmd/apply.go
+++ b/cmd/apply.go
@@ -5,17 +5,17 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var applyCommand = &cobra.Command{
+var applyCmd = &cobra.Command{
 	Use:   "apply [targets...]",
 	Short: "Update the destination directory to match the target state",
-	RunE:  makeRunE(config.runApplyCommand),
+	RunE:  makeRunE(config.runApplyCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(applyCommand)
+	rootCmd.AddCommand(applyCmd)
 }
 
-func (c *Config) runApplyCommand(fs vfs.FS, args []string) error {
+func (c *Config) runApplyCmd(fs vfs.FS, args []string) error {
 	mutator := c.getDefaultMutator(fs)
 	return c.applyArgs(fs, args, mutator)
 }
diff --git a/cmd/archive.go b/cmd/archive.go
index 8b9e7e209..78559ac57 100644
--- a/cmd/archive.go
+++ b/cmd/archive.go
@@ -8,18 +8,18 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var archiveCommand = &cobra.Command{
+var archiveCmd = &cobra.Command{
 	Use:   "archive",
 	Args:  cobra.NoArgs,
 	Short: "Write a tar archive of the target state to stdout",
-	RunE:  makeRunE(config.runArchiveCommand),
+	RunE:  makeRunE(config.runArchiveCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(archiveCommand)
+	rootCmd.AddCommand(archiveCmd)
 }
 
-func (c *Config) runArchiveCommand(fs vfs.FS, args []string) error {
+func (c *Config) runArchiveCmd(fs vfs.FS, args []string) error {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/cat.go b/cmd/cat.go
index 96acd0a78..8a71a4fa1 100644
--- a/cmd/cat.go
+++ b/cmd/cat.go
@@ -9,18 +9,18 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var catCommand = &cobra.Command{
+var catCmd = &cobra.Command{
 	Use:   "cat targets...",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Write the target state of a file or symlink to stdout",
-	RunE:  makeRunE(config.runCatCommand),
+	RunE:  makeRunE(config.runCatCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(catCommand)
+	rootCmd.AddCommand(catCmd)
 }
 
-func (c *Config) runCatCommand(fs vfs.FS, args []string) error {
+func (c *Config) runCatCmd(fs vfs.FS, args []string) error {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/cd.go b/cmd/cd.go
index c5a593a0f..a182e9208 100644
--- a/cmd/cd.go
+++ b/cmd/cd.go
@@ -8,18 +8,23 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var cdCommand = &cobra.Command{
+var cdCmd = &cobra.Command{
 	Use:   "cd",
 	Args:  cobra.NoArgs,
 	Short: "Launch a shell in the source directory",
-	RunE:  makeRunE(config.runCDCommand),
+	RunE:  makeRunE(config.runCDCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(cdCommand)
+	rootCmd.AddCommand(cdCmd)
 }
 
-func (c *Config) runCDCommand(fs vfs.FS, args []string) error {
+func (c *Config) runCDCmd(fs vfs.FS, args []string) error {
+	mutator := c.getDefaultMutator(fs)
+	if err := c.ensureSourceDirectory(fs, mutator); err != nil {
+		return err
+	}
+
 	if err := os.Chdir(c.SourceDir); err != nil {
 		return err
 	}
diff --git a/cmd/chattr.go b/cmd/chattr.go
index 534d2b451..84463b9bd 100644
--- a/cmd/chattr.go
+++ b/cmd/chattr.go
@@ -12,11 +12,11 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var chattrCommand = &cobra.Command{
+var chattrCmd = &cobra.Command{
 	Use:   "chattr attributes targets...",
 	Args:  cobra.MinimumNArgs(2),
 	Short: "Change the attributes of a target in the source state",
-	RunE:  makeRunE(config.runChattrCommand),
+	RunE:  makeRunE(config.runChattrCmd),
 }
 
 type boolModifier int
@@ -30,10 +30,10 @@ type attributeModifiers struct {
 }
 
 func init() {
-	rootCommand.AddCommand(chattrCommand)
+	rootCmd.AddCommand(chattrCmd)
 }
 
-func (c *Config) runChattrCommand(fs vfs.FS, args []string) error {
+func (c *Config) runChattrCmd(fs vfs.FS, args []string) error {
 	ams, err := parseAttributeModifiers(args[0])
 	if err != nil {
 		return err
diff --git a/cmd/config.go b/cmd/config.go
index 08832ea37..4e6c4d315 100644
--- a/cmd/config.go
+++ b/cmd/config.go
@@ -39,22 +39,22 @@ type Config struct {
 	DryRun        bool
 	Verbose       bool
 	SourceVCS     sourceVCSConfig
-	Bitwarden     bitwardenCommandConfig
-	GenericSecret genericSecretCommandConfig
-	LastPass      lastpassCommandConfig
-	OnePassword   onepasswordCommandConfig
-	Vault         vaultCommandConfig
-	Pass          passCommandConfig
+	Bitwarden     bitwardenCmdConfig
+	GenericSecret genericSecretCmdConfig
+	Lastpass      lastpassCmdConfig
+	Onepassword   onepasswordCmdConfig
+	Vault         vaultCmdConfig
+	Pass          passCmdConfig
 	Data          map[string]interface{}
 	templateFuncs template.FuncMap
-	add           addCommandConfig
-	data          dataCommandConfig
-	dump          dumpCommandConfig
-	edit          editCommandConfig
-	init          initCommandConfig
-	_import       importCommandConfig
-	keyring       keyringCommandConfig
-	update        updateCommandConfig
+	add           addCmdConfig
+	data          dataCmdConfig
+	dump          dumpCmdConfig
+	edit          editCmdConfig
+	init          initCmdConfig
+	_import       importCmdConfig
+	keyring       keyringCmdConfig
+	update        updateCmdConfig
 }
 
 var (
@@ -321,9 +321,9 @@ func isWellKnownAbbreviation(word string) bool {
 	return ok
 }
 
-func makeRunE(runCommand func(vfs.FS, []string) error) func(*cobra.Command, []string) error {
+func makeRunE(runCmd func(vfs.FS, []string) error) func(*cobra.Command, []string) error {
 	return func(cmd *cobra.Command, args []string) error {
-		return runCommand(vfs.OSFS, args)
+		return runCmd(vfs.OSFS, args)
 	}
 }
 
diff --git a/cmd/data.go b/cmd/data.go
index a3ab00a74..845938adc 100644
--- a/cmd/data.go
+++ b/cmd/data.go
@@ -9,24 +9,24 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-type dataCommandConfig struct {
+type dataCmdConfig struct {
 	format string
 }
 
-var dataCommand = &cobra.Command{
+var dataCmd = &cobra.Command{
 	Use:   "data",
 	Short: "Write the template data to stdout",
-	RunE:  makeRunE(config.runDataCommand),
+	RunE:  makeRunE(config.runDataCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(dataCommand)
+	rootCmd.AddCommand(dataCmd)
 
-	persistentFlags := dataCommand.PersistentFlags()
+	persistentFlags := dataCmd.PersistentFlags()
 	persistentFlags.StringVarP(&config.data.format, "format", "f", "json", "format (JSON or YAML)")
 }
 
-func (c *Config) runDataCommand(fs vfs.FS, args []string) error {
+func (c *Config) runDataCmd(fs vfs.FS, args []string) error {
 	format, ok := formatMap[strings.ToLower(c.data.format)]
 	if !ok {
 		return fmt.Errorf("%s: unknown format", c.data.format)
diff --git a/cmd/diff.go b/cmd/diff.go
index 9e990ad9d..ac12a892a 100644
--- a/cmd/diff.go
+++ b/cmd/diff.go
@@ -8,17 +8,17 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var diffCommand = &cobra.Command{
+var diffCmd = &cobra.Command{
 	Use:   "diff [targets...]",
 	Short: "Write the diff between the target state and the destination state to stdout",
-	RunE:  makeRunE(config.runDiffCommand),
+	RunE:  makeRunE(config.runDiffCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(diffCommand)
+	rootCmd.AddCommand(diffCmd)
 }
 
-func (c *Config) runDiffCommand(fs vfs.FS, args []string) error {
+func (c *Config) runDiffCmd(fs vfs.FS, args []string) error {
 	mutator := chezmoi.NewLoggingMutator(os.Stdout, chezmoi.NullMutator)
 	return c.applyArgs(fs, args, mutator)
 }
diff --git a/cmd/doctor.go b/cmd/doctor.go
index d68a00dda..9e86b5478 100644
--- a/cmd/doctor.go
+++ b/cmd/doctor.go
@@ -12,11 +12,11 @@ import (
 )
 
 // doctorCmd represents the doctor command
-var doctorCommand = &cobra.Command{
+var doctorCmd = &cobra.Command{
 	Args:  cobra.NoArgs,
 	Use:   "doctor",
 	Short: "Check your system for potential problems",
-	RunE:  makeRunE(config.runDoctorCommandE),
+	RunE:  makeRunE(config.runDoctorCmd),
 }
 
 const (
@@ -64,10 +64,10 @@ type doctorFileCheck struct {
 }
 
 func init() {
-	rootCommand.AddCommand(doctorCommand)
+	rootCmd.AddCommand(doctorCmd)
 }
 
-func (c *Config) runDoctorCommandE(fs vfs.FS, args []string) error {
+func (c *Config) runDoctorCmd(fs vfs.FS, args []string) error {
 	var vcsCommandCheck doctorCheck
 	if vcsInfo, err := c.getVCSInfo(); err == nil {
 		vcsCommandCheck = &doctorBinaryCheck{
@@ -107,7 +107,7 @@ func (c *Config) runDoctorCommandE(fs vfs.FS, args []string) error {
 		vcsCommandCheck,
 		&doctorBinaryCheck{
 			name:          "1Password CLI",
-			binaryName:    c.OnePassword.Op,
+			binaryName:    c.Onepassword.Op,
 			versionArgs:   []string{"--version"},
 			versionRegexp: regexp.MustCompile(`^(\d+\.\d+\.\d+)`),
 		},
@@ -119,7 +119,7 @@ func (c *Config) runDoctorCommandE(fs vfs.FS, args []string) error {
 		},
 		&doctorBinaryCheck{
 			name:          "LastPass CLI",
-			binaryName:    c.LastPass.Lpass,
+			binaryName:    c.Lastpass.Lpass,
 			versionArgs:   []string{"--version"},
 			versionRegexp: regexp.MustCompile(`^LastPass CLI v(\d+\.\d+\.\d+)`),
 			// chezmoi uses lpass show --json which was added in
diff --git a/cmd/dump.go b/cmd/dump.go
index 71c8ecc75..7b8b1a87d 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -9,26 +9,26 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-type dumpCommandConfig struct {
+type dumpCmdConfig struct {
 	format    string
 	recursive bool
 }
 
-var dumpCommand = &cobra.Command{
+var dumpCmd = &cobra.Command{
 	Use:   "dump [targets...]",
 	Short: "Write a dump of the target state to stdout",
-	RunE:  makeRunE(config.runDumpCommand),
+	RunE:  makeRunE(config.runDumpCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(dumpCommand)
+	rootCmd.AddCommand(dumpCmd)
 
-	persistentFlags := dumpCommand.PersistentFlags()
+	persistentFlags := dumpCmd.PersistentFlags()
 	persistentFlags.StringVarP(&config.dump.format, "format", "f", "json", "format (JSON or YAML)")
 	persistentFlags.BoolVarP(&config.dump.recursive, "recursive", "r", true, "recursive")
 }
 
-func (c *Config) runDumpCommand(fs vfs.FS, args []string) error {
+func (c *Config) runDumpCmd(fs vfs.FS, args []string) error {
 	format, ok := formatMap[strings.ToLower(c.dump.format)]
 	if !ok {
 		return fmt.Errorf("%s: unknown format", c.dump.format)
diff --git a/cmd/edit.go b/cmd/edit.go
index 781a801f9..cea996338 100644
--- a/cmd/edit.go
+++ b/cmd/edit.go
@@ -10,29 +10,29 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var editCommand = &cobra.Command{
+var editCmd = &cobra.Command{
 	Use:   "edit targets...",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Edit the source state of a target",
-	RunE:  makeRunE(config.runEditCommand),
+	RunE:  makeRunE(config.runEditCmd),
 }
 
-type editCommandConfig struct {
+type editCmdConfig struct {
 	apply  bool
 	diff   bool
 	prompt bool
 }
 
 func init() {
-	rootCommand.AddCommand(editCommand)
+	rootCmd.AddCommand(editCmd)
 
-	persistentFlags := editCommand.PersistentFlags()
+	persistentFlags := editCmd.PersistentFlags()
 	persistentFlags.BoolVarP(&config.edit.apply, "apply", "a", false, "apply edit after editing")
 	persistentFlags.BoolVarP(&config.edit.diff, "diff", "d", false, "print diff after editing")
 	persistentFlags.BoolVarP(&config.edit.prompt, "prompt", "p", false, "prompt before applying (implies --diff)")
 }
 
-func (c *Config) runEditCommand(fs vfs.FS, args []string) error {
+func (c *Config) runEditCmd(fs vfs.FS, args []string) error {
 	if c.edit.prompt {
 		c.edit.diff = true
 	}
diff --git a/cmd/edit_config.go b/cmd/edit_config.go
index 9dec44f58..7d38beaf6 100644
--- a/cmd/edit_config.go
+++ b/cmd/edit_config.go
@@ -9,13 +9,13 @@ var editConfigCommand = &cobra.Command{
 	Use:   "edit-config",
 	Args:  cobra.NoArgs,
 	Short: "Edit the configuration file",
-	RunE:  makeRunE(config.runEditConfigCommand),
+	RunE:  makeRunE(config.runEditConfigCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(editConfigCommand)
+	rootCmd.AddCommand(editConfigCommand)
 }
 
-func (c *Config) runEditConfigCommand(fs vfs.FS, args []string) error {
+func (c *Config) runEditConfigCmd(fs vfs.FS, args []string) error {
 	return c.execEditor(c.configFile)
 }
diff --git a/cmd/forget.go b/cmd/forget.go
index 207ca4f37..1df944f9c 100644
--- a/cmd/forget.go
+++ b/cmd/forget.go
@@ -7,18 +7,18 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var forgetCommand = &cobra.Command{
+var forgetCmd = &cobra.Command{
 	Use:   "forget targets...",
 	Args:  cobra.MinimumNArgs(1),
 	Short: "Remove a target from the source state",
-	RunE:  makeRunE(config.runForgetCommand),
+	RunE:  makeRunE(config.runForgetCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(forgetCommand)
+	rootCmd.AddCommand(forgetCmd)
 }
 
-func (c *Config) runForgetCommand(fs vfs.FS, args []string) error {
+func (c *Config) runForgetCmd(fs vfs.FS, args []string) error {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/import.go b/cmd/import.go
index 7426052e4..97ae5931e 100644
--- a/cmd/import.go
+++ b/cmd/import.go
@@ -15,29 +15,29 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var _importCommand = &cobra.Command{
+var _importCmd = &cobra.Command{
 	Use:   "import [filename]",
 	Args:  cobra.MaximumNArgs(1),
 	Short: "Import a tar archive into the source state",
-	RunE:  makeRunE(config.runImportCommand),
+	RunE:  makeRunE(config.runImportCmd),
 }
 
-type importCommandConfig struct {
+type importCmdConfig struct {
 	removeDestination bool
 	importTAROptions  chezmoi.ImportTAROptions
 }
 
 func init() {
-	rootCommand.AddCommand(_importCommand)
+	rootCmd.AddCommand(_importCmd)
 
-	persistentFlags := _importCommand.PersistentFlags()
+	persistentFlags := _importCmd.PersistentFlags()
 	persistentFlags.StringVarP(&config._import.importTAROptions.DestinationDir, "destination", "d", "", "destination prefix")
 	persistentFlags.BoolVarP(&config._import.importTAROptions.Exact, "exact", "x", false, "import directories exactly")
 	persistentFlags.IntVar(&config._import.importTAROptions.StripComponents, "strip-components", 0, "strip components")
 	persistentFlags.BoolVarP(&config._import.removeDestination, "remove-destination", "r", false, "remove destination before import")
 }
 
-func (c *Config) runImportCommand(fs vfs.FS, args []string) error {
+func (c *Config) runImportCmd(fs vfs.FS, args []string) error {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/init.go b/cmd/init.go
index 3a9bae508..7fcdcc386 100644
--- a/cmd/init.go
+++ b/cmd/init.go
@@ -9,8 +9,7 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-// initCmd represents the init command
-var initCommand = &cobra.Command{
+var initCmd = &cobra.Command{
 	Args:  cobra.MaximumNArgs(1),
 	Use:   "init [repo]",
 	Short: "Initial setup of the source directory then update the destination directory to match the target state",
@@ -21,8 +20,8 @@ new host. It will clone the given repository into your source directory (see --s
 and make sure that all directory permissions are correct.
 
 After your source directory was checked out and setup (e.g. git submodules) this
-command will automatically invoke the "apply" command to update the destination
-directory. You can use the --apply=false flag to prevent this from happening.
+command will can automatically invoke the "apply" command to update the destination
+directory if you supply the flag.
 `,
 	Example: `
   # Checkout from github using the public HTTPS API
@@ -31,21 +30,21 @@ directory. You can use the --apply=false flag to prevent this from happening.
   # Checkout from github using your private key
   chezmoi init git@github.com:example/dotfiles.git
 `,
-	RunE: makeRunE(config.runInitCommand),
+	RunE: makeRunE(config.runInitCmd),
 }
 
-type initCommandConfig struct {
+type initCmdConfig struct {
 	apply bool
 }
 
 func init() {
-	rootCommand.AddCommand(initCommand)
+	rootCmd.AddCommand(initCmd)
 
-	persistentFlags := initCommand.PersistentFlags()
-	persistentFlags.BoolVar(&config.init.apply, "apply", true, "update destination directory")
+	persistentFlags := initCmd.PersistentFlags()
+	persistentFlags.BoolVar(&config.init.apply, "apply", false, "update destination directory")
 }
 
-func (c *Config) runInitCommand(fs vfs.FS, args []string) error {
+func (c *Config) runInitCmd(fs vfs.FS, args []string) error {
 	vcsInfo, err := c.getVCSInfo()
 	if err != nil {
 		return err
diff --git a/cmd/remove.go b/cmd/remove.go
index d66b09e79..a4ce4b8f2 100644
--- a/cmd/remove.go
+++ b/cmd/remove.go
@@ -8,19 +8,19 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var removeCommand = &cobra.Command{
+var removeCmd = &cobra.Command{
 	Use:     "remove targets...",
 	Aliases: []string{"rm"},
 	Args:    cobra.MinimumNArgs(1),
 	Short:   "Remove a target from the source state and the destination directory",
-	RunE:    makeRunE(config.runRemoveCommand),
+	RunE:    makeRunE(config.runRemoveCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(removeCommand)
+	rootCmd.AddCommand(removeCmd)
 }
 
-func (c *Config) runRemoveCommand(fs vfs.FS, args []string) error {
+func (c *Config) runRemoveCmd(fs vfs.FS, args []string) error {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/root.go b/cmd/root.go
index 402e858f0..48f6aacbf 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -23,7 +23,7 @@ var (
 	date    = "unknown"
 )
 
-var rootCommand = &cobra.Command{
+var rootCmd = &cobra.Command{
 	Use:               "chezmoi",
 	Short:             "Manage your dotfiles across multiple machines, securely",
 	SilenceErrors:     true,
@@ -32,7 +32,7 @@ var rootCommand = &cobra.Command{
 }
 
 func init() {
-	rootCommand.Version = fmt.Sprintf("%s, commit %s, built at %s", version, commit, date)
+	rootCmd.Version = fmt.Sprintf("%s, commit %s, built at %s", version, commit, date)
 
 	homeDir, err := homedir.Dir()
 	if err != nil {
@@ -44,7 +44,7 @@ func init() {
 		printErrorAndExit(err)
 	}
 
-	persistentFlags := rootCommand.PersistentFlags()
+	persistentFlags := rootCmd.PersistentFlags()
 
 	persistentFlags.StringVarP(&config.configFile, "config", "c", getDefaultConfigFile(x, homeDir), "config file")
 
@@ -78,7 +78,7 @@ func init() {
 
 // Execute executes the root command.
 func Execute() {
-	if err := rootCommand.Execute(); err != nil {
+	if err := rootCmd.Execute(); err != nil {
 		printErrorAndExit(err)
 	}
 }
diff --git a/cmd/secret.go b/cmd/secret.go
index 16841c1c8..1700fe8a2 100644
--- a/cmd/secret.go
+++ b/cmd/secret.go
@@ -2,12 +2,12 @@ package cmd
 
 import "github.com/spf13/cobra"
 
-var secretCommand = &cobra.Command{
+var secretCmd = &cobra.Command{
 	Use:   "secret",
 	Args:  cobra.NoArgs,
 	Short: "Interact with a secret manager",
 }
 
 func init() {
-	rootCommand.AddCommand(secretCommand)
+	rootCmd.AddCommand(secretCmd)
 }
diff --git a/cmd/secret_bitwarden.go b/cmd/secret_bitwarden.go
index 7d98412cd..6595b0b2a 100644
--- a/cmd/secret_bitwarden.go
+++ b/cmd/secret_bitwarden.go
@@ -11,13 +11,13 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var bitwardenCommand = &cobra.Command{
+var bitwardenCmd = &cobra.Command{
 	Use:   "bitwarden [args...]",
 	Short: "Execute the Bitwarden CLI (bw)",
-	RunE:  makeRunE(config.runBitwardenCommand),
+	RunE:  makeRunE(config.runBitwardenCmd),
 }
 
-type bitwardenCommandConfig struct {
+type bitwardenCmdConfig struct {
 	Bw string
 }
 
@@ -27,10 +27,10 @@ func init() {
 	config.Bitwarden.Bw = "bw"
 	config.addTemplateFunc("bitwarden", config.bitwardenFunc)
 
-	secretCommand.AddCommand(bitwardenCommand)
+	secretCmd.AddCommand(bitwardenCmd)
 }
 
-func (c *Config) runBitwardenCommand(fs vfs.FS, args []string) error {
+func (c *Config) runBitwardenCmd(fs vfs.FS, args []string) error {
 	return c.exec(append([]string{c.Bitwarden.Bw}, args...))
 }
 
diff --git a/cmd/secret_generic.go b/cmd/secret_generic.go
index 2911da770..e3ef46557 100644
--- a/cmd/secret_generic.go
+++ b/cmd/secret_generic.go
@@ -11,13 +11,13 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var genericSecretCommand = &cobra.Command{
+var genericSecretCmd = &cobra.Command{
 	Use:   "generic [args...]",
 	Short: "Execute a generic secret command",
-	RunE:  makeRunE(config.runGenericSecretCommand),
+	RunE:  makeRunE(config.runGenericSecretCmd),
 }
 
-type genericSecretCommandConfig struct {
+type genericSecretCmdConfig struct {
 	Command string
 }
 
@@ -27,10 +27,10 @@ func init() {
 	config.addTemplateFunc("secret", config.secretFunc)
 	config.addTemplateFunc("secretJSON", config.secretJSONFunc)
 
-	secretCommand.AddCommand(genericSecretCommand)
+	secretCmd.AddCommand(genericSecretCmd)
 }
 
-func (c *Config) runGenericSecretCommand(fs vfs.FS, args []string) error {
+func (c *Config) runGenericSecretCmd(fs vfs.FS, args []string) error {
 	return c.exec(append([]string{c.GenericSecret.Command}, args...))
 }
 
diff --git a/cmd/secret_keyring.go b/cmd/secret_keyring.go
index f7c0983e1..0e3368299 100644
--- a/cmd/secret_keyring.go
+++ b/cmd/secret_keyring.go
@@ -8,13 +8,13 @@ import (
 	keyring "github.com/zalando/go-keyring"
 )
 
-var keyringCommand = &cobra.Command{
+var keyringCmd = &cobra.Command{
 	Use:   "keyring",
 	Args:  cobra.NoArgs,
 	Short: "Interact with keyring",
 }
 
-type keyringCommandConfig struct {
+type keyringCmdConfig struct {
 	service  string
 	user     string
 	password string
@@ -28,15 +28,15 @@ type keyringKey struct {
 var keyringCache = make(map[keyringKey]string)
 
 func init() {
-	secretCommand.AddCommand(keyringCommand)
+	secretCmd.AddCommand(keyringCmd)
 
-	persistentFlags := keyringCommand.PersistentFlags()
+	persistentFlags := keyringCmd.PersistentFlags()
 
 	persistentFlags.StringVar(&config.keyring.service, "service", "", "service")
-	keyringCommand.MarkPersistentFlagRequired("service")
+	keyringCmd.MarkPersistentFlagRequired("service")
 
 	persistentFlags.StringVar(&config.keyring.user, "user", "", "user")
-	keyringCommand.MarkPersistentFlagRequired("user")
+	keyringCmd.MarkPersistentFlagRequired("user")
 
 	config.addTemplateFunc("keyring", config.keyringFunc)
 }
diff --git a/cmd/secret_keyring_get.go b/cmd/secret_keyring_get.go
index ed4f2cb6d..f4453e6e3 100644
--- a/cmd/secret_keyring_get.go
+++ b/cmd/secret_keyring_get.go
@@ -8,18 +8,18 @@ import (
 	keyring "github.com/zalando/go-keyring"
 )
 
-var keyringGetCommand = &cobra.Command{
+var keyringGetCmd = &cobra.Command{
 	Use:   "get",
 	Args:  cobra.NoArgs,
 	Short: "Get a password from keyring",
-	RunE:  makeRunE(config.runKeyringGetCommand),
+	RunE:  makeRunE(config.runKeyringGetCmd),
 }
 
 func init() {
-	keyringCommand.AddCommand(keyringGetCommand)
+	keyringCmd.AddCommand(keyringGetCmd)
 }
 
-func (c *Config) runKeyringGetCommand(fs vfs.FS, args []string) error {
+func (c *Config) runKeyringGetCmd(fs vfs.FS, args []string) error {
 	password, err := keyring.Get(c.keyring.service, c.keyring.user)
 	if err != nil {
 		return err
diff --git a/cmd/secret_keyring_set.go b/cmd/secret_keyring_set.go
index 2a64a430b..c466b8421 100644
--- a/cmd/secret_keyring_set.go
+++ b/cmd/secret_keyring_set.go
@@ -10,21 +10,21 @@ import (
 	"golang.org/x/crypto/ssh/terminal"
 )
 
-var keyringSetCommand = &cobra.Command{
+var keyringSetCmd = &cobra.Command{
 	Use:   "set",
 	Args:  cobra.NoArgs,
 	Short: "Set a password in keyring",
-	RunE:  makeRunE(config.runKeyringSetCommand),
+	RunE:  makeRunE(config.runKeyringSetCmd),
 }
 
 func init() {
-	keyringCommand.AddCommand(keyringSetCommand)
+	keyringCmd.AddCommand(keyringSetCmd)
 
-	persistentFlags := keyringSetCommand.PersistentFlags()
+	persistentFlags := keyringSetCmd.PersistentFlags()
 	persistentFlags.StringVar(&config.keyring.password, "password", "", "password")
 }
 
-func (c *Config) runKeyringSetCommand(fs vfs.FS, args []string) error {
+func (c *Config) runKeyringSetCmd(fs vfs.FS, args []string) error {
 	passwordString := c.keyring.password
 	if passwordString == "" {
 		fmt.Print("Password: ")
diff --git a/cmd/secret_lastpass.go b/cmd/secret_lastpass.go
index 994c88d91..1844ddea0 100644
--- a/cmd/secret_lastpass.go
+++ b/cmd/secret_lastpass.go
@@ -15,36 +15,36 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var lastpassCommand = &cobra.Command{
+var lastpassCmd = &cobra.Command{
 	Use:   "lastpass [args...]",
 	Short: "Execute the LastPass CLI (lpass)",
-	RunE:  makeRunE(config.runLastPassCommand),
+	RunE:  makeRunE(config.runLastpassCmd),
 }
 
 var lastpassParseNoteRegexp = regexp.MustCompile(`\A([ A-Za-z]*):(.*)\z`)
 
-type lastpassCommandConfig struct {
+type lastpassCmdConfig struct {
 	Lpass string
 }
 
 var lastPassCache = make(map[string]interface{})
 
 func init() {
-	config.LastPass.Lpass = "lpass"
+	config.Lastpass.Lpass = "lpass"
 	config.addTemplateFunc("lastpass", config.lastpassFunc)
 
-	secretCommand.AddCommand(lastpassCommand)
+	secretCmd.AddCommand(lastpassCmd)
 }
 
-func (c *Config) runLastPassCommand(fs vfs.FS, args []string) error {
-	return c.exec(append([]string{c.LastPass.Lpass}, args...))
+func (c *Config) runLastpassCmd(fs vfs.FS, args []string) error {
+	return c.exec(append([]string{c.Lastpass.Lpass}, args...))
 }
 
 func (c *Config) lastpassFunc(id string) interface{} {
 	if data, ok := lastPassCache[id]; ok {
 		return data
 	}
-	name := c.LastPass.Lpass
+	name := c.Lastpass.Lpass
 	args := []string{"show", "-j", id}
 	if c.Verbose {
 		fmt.Printf("%s %s\n", name, strings.Join(args, " "))
diff --git a/cmd/secret_onepassword.go b/cmd/secret_onepassword.go
index be7a55b0e..4f4a8d086 100644
--- a/cmd/secret_onepassword.go
+++ b/cmd/secret_onepassword.go
@@ -11,34 +11,34 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var onepasswordCommand = &cobra.Command{
+var onepasswordCmd = &cobra.Command{
 	Use:   "onepassword [args...]",
 	Short: "Execute the 1Password CLI (op)",
-	RunE:  makeRunE(config.runOnePasswordCommand),
+	RunE:  makeRunE(config.runOnepasswordCmd),
 }
 
-type onepasswordCommandConfig struct {
+type onepasswordCmdConfig struct {
 	Op string
 }
 
 var onepasswordCache = make(map[string]interface{})
 
 func init() {
-	config.OnePassword.Op = "op"
+	config.Onepassword.Op = "op"
 	config.addTemplateFunc("onepassword", config.onepasswordFunc)
 
-	secretCommand.AddCommand(onepasswordCommand)
+	secretCmd.AddCommand(onepasswordCmd)
 }
 
-func (c *Config) runOnePasswordCommand(fs vfs.FS, args []string) error {
-	return c.exec(append([]string{c.OnePassword.Op}, args...))
+func (c *Config) runOnepasswordCmd(fs vfs.FS, args []string) error {
+	return c.exec(append([]string{c.Onepassword.Op}, args...))
 }
 
 func (c *Config) onepasswordFunc(item string) interface{} {
 	if data, ok := onepasswordCache[item]; ok {
 		return data
 	}
-	name := c.OnePassword.Op
+	name := c.Onepassword.Op
 	args := []string{"get", "item", item}
 	if c.Verbose {
 		fmt.Printf("%s %s\n", name, strings.Join(args, " "))
diff --git a/cmd/secret_pass.go b/cmd/secret_pass.go
index 9b93039cc..eeb7d54d5 100644
--- a/cmd/secret_pass.go
+++ b/cmd/secret_pass.go
@@ -11,26 +11,26 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var passCommand = &cobra.Command{
+var passCmd = &cobra.Command{
 	Use:   "pass [args...]",
 	Short: "Execute the pass CLI",
-	RunE:  makeRunE(config.runPassCommand),
+	RunE:  makeRunE(config.runSecretPassCmd),
 }
 
-type passCommandConfig struct {
+type passCmdConfig struct {
 	Pass string
 }
 
 var passCache = make(map[string]string)
 
 func init() {
-	secretCommand.AddCommand(passCommand)
+	secretCmd.AddCommand(passCmd)
 
 	config.Pass.Pass = "pass"
 	config.addTemplateFunc("pass", config.passFunc)
 }
 
-func (c *Config) runPassCommand(fs vfs.FS, args []string) error {
+func (c *Config) runSecretPassCmd(fs vfs.FS, args []string) error {
 	return c.exec(append([]string{c.Pass.Pass}, args...))
 }
 
diff --git a/cmd/secret_vault.go b/cmd/secret_vault.go
index 5fb9969e7..96c53b346 100644
--- a/cmd/secret_vault.go
+++ b/cmd/secret_vault.go
@@ -11,13 +11,13 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var vaultCommand = &cobra.Command{
+var vaultCmd = &cobra.Command{
 	Use:   "vault [args...]",
 	Short: "Execute the Hashicorp Vault CLI (vault)",
-	RunE:  makeRunE(config.runVaultCommand),
+	RunE:  makeRunE(config.runVaultCmd),
 }
 
-type vaultCommandConfig struct {
+type vaultCmdConfig struct {
 	Vault string
 }
 
@@ -27,10 +27,10 @@ func init() {
 	config.Vault.Vault = "vault"
 	config.addTemplateFunc("vault", config.vaultFunc)
 
-	secretCommand.AddCommand(vaultCommand)
+	secretCmd.AddCommand(vaultCmd)
 }
 
-func (c *Config) runVaultCommand(fs vfs.FS, args []string) error {
+func (c *Config) runVaultCmd(fs vfs.FS, args []string) error {
 	return c.exec(append([]string{c.Vault.Vault}, args...))
 }
 
diff --git a/cmd/source.go b/cmd/source.go
index fb80c16ee..b820b19f3 100644
--- a/cmd/source.go
+++ b/cmd/source.go
@@ -8,17 +8,17 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var sourceCommand = &cobra.Command{
+var sourceCmd = &cobra.Command{
 	Use:   "source [args...]",
 	Short: "Run the source version control system command in the source directory",
-	RunE:  makeRunE(config.runSourceCommand),
+	RunE:  makeRunE(config.runSourceCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(sourceCommand)
+	rootCmd.AddCommand(sourceCmd)
 }
 
-func (c *Config) runSourceCommand(fs vfs.FS, args []string) error {
+func (c *Config) runSourceCmd(fs vfs.FS, args []string) error {
 	if c.Verbose {
 		fmt.Printf("cd %s\n", c.SourceDir)
 	}
diff --git a/cmd/source_path.go b/cmd/source_path.go
index 2e81c17fe..7e0cd34ef 100644
--- a/cmd/source_path.go
+++ b/cmd/source_path.go
@@ -8,17 +8,17 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var sourcePathCommand = &cobra.Command{
+var sourcePathCmd = &cobra.Command{
 	Use:   "source-path [targets...]",
 	Short: "Print the path of a target in the source state",
-	RunE:  makeRunE(config.runSourcePathCommand),
+	RunE:  makeRunE(config.runSourcePathCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(sourcePathCommand)
+	rootCmd.AddCommand(sourcePathCmd)
 }
 
-func (c *Config) runSourcePathCommand(fs vfs.FS, args []string) error {
+func (c *Config) runSourcePathCmd(fs vfs.FS, args []string) error {
 	ts, err := c.getTargetState(fs)
 	if err != nil {
 		return err
diff --git a/cmd/update.go b/cmd/update.go
index 89bab0190..9a0f2ae5a 100644
--- a/cmd/update.go
+++ b/cmd/update.go
@@ -8,25 +8,25 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-type updateCommandConfig struct {
+type updateCmdConfig struct {
 	apply bool
 }
 
-var updateCommand = &cobra.Command{
+var updateCmd = &cobra.Command{
 	Use:   "update",
 	Args:  cobra.NoArgs,
 	Short: "Pull changes from the source VCS and apply any changes",
-	RunE:  makeRunE(config.runUpdateCommand),
+	RunE:  makeRunE(config.runUpdateCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(updateCommand)
+	rootCmd.AddCommand(updateCmd)
 
-	persistentFlags := updateCommand.PersistentFlags()
+	persistentFlags := updateCmd.PersistentFlags()
 	persistentFlags.BoolVarP(&config.update.apply, "apply", "a", true, "apply after pulling")
 }
 
-func (c *Config) runUpdateCommand(fs vfs.FS, args []string) error {
+func (c *Config) runUpdateCmd(fs vfs.FS, args []string) error {
 	vcsInfo, err := c.getVCSInfo()
 	if err != nil {
 		return err
diff --git a/cmd/verify.go b/cmd/verify.go
index 6cfa6e528..6e675c07a 100644
--- a/cmd/verify.go
+++ b/cmd/verify.go
@@ -8,17 +8,17 @@ import (
 	vfs "github.com/twpayne/go-vfs"
 )
 
-var verifyCommand = &cobra.Command{
+var verifyCmd = &cobra.Command{
 	Use:   "verify [targets...]",
 	Short: "Exit with success if the destination state matches the target state, fail otherwise",
-	RunE:  makeRunE(config.runVerifyCommand),
+	RunE:  makeRunE(config.runVerifyCmd),
 }
 
 func init() {
-	rootCommand.AddCommand(verifyCommand)
+	rootCmd.AddCommand(verifyCmd)
 }
 
-func (c *Config) runVerifyCommand(fs vfs.FS, args []string) error {
+func (c *Config) runVerifyCmd(fs vfs.FS, args []string) error {
 	mutator := chezmoi.NewAnyMutator(chezmoi.NullMutator)
 	if err := c.applyArgs(fs, args, mutator); err != nil {
 		return err


Test patch:
diff --git a/cmd/add_test.go b/cmd/add_test.go
index c3c2be0af..342a0084c 100644
--- a/cmd/add_test.go
+++ b/cmd/add_test.go
@@ -25,8 +25,8 @@ func TestAddAfterModification(t *testing.T) {
 		t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 	}
 	args := []string{"/home/user/.bashrc"}
-	if err := c.runAddCommand(fs, args); err != nil {
-		t.Errorf("c.runAddCommand(fs, nil, %+v) == %v, want <nil>", args, err)
+	if err := c.runAddCmd(fs, args); err != nil {
+		t.Errorf("c.runAddCmd(fs, nil, %+v) == %v, want <nil>", args, err)
 	}
 	vfst.RunTests(t, fs, "",
 		vfst.TestPath("/home/user/.chezmoi/dot_bashrc",
@@ -37,8 +37,8 @@ func TestAddAfterModification(t *testing.T) {
 	if err := fs.WriteFile("/home/user/.bashrc", []byte("# new contents of .bashrc\n"), 0644); err != nil {
 		t.Errorf("fs.WriteFile(...) == %v, want <nil>", err)
 	}
-	if err := c.runAddCommand(fs, args); err != nil {
-		t.Errorf("c.runAddCommand(fs, nil, %+v) == %v, want <nil>", args, err)
+	if err := c.runAddCmd(fs, args); err != nil {
+		t.Errorf("c.runAddCmd(fs, nil, %+v) == %v, want <nil>", args, err)
 	}
 	vfst.RunTests(t, fs, "",
 		vfst.TestPath("/home/user/.chezmoi/dot_bashrc",
@@ -52,7 +52,7 @@ func TestAddCommand(t *testing.T) {
 	for _, tc := range []struct {
 		name  string
 		args  []string
-		add   addCommandConfig
+		add   addCmdConfig
 		root  interface{}
 		tests interface{}
 	}{
@@ -76,7 +76,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "add_template",
 			args: []string{"/home/user/.gitconfig"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				options: chezmoi.AddOptions{
 					Template: true,
 				},
@@ -96,7 +96,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "add_recursive",
 			args: []string{"/home/user/.config"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				recursive: true,
 			},
 			root: map[string]interface{}{
@@ -129,7 +129,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "add_exact_dir",
 			args: []string{"/home/user/dir"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				options: chezmoi.AddOptions{
 					Exact: true,
 				},
@@ -148,7 +148,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "add_exact_dir_recursive",
 			args: []string{"/home/user/dir"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				recursive: true,
 				options: chezmoi.AddOptions{
 					Exact: true,
@@ -174,7 +174,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "add_empty_file",
 			args: []string{"/home/user/empty"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				options: chezmoi.AddOptions{
 					Empty: true,
 				},
@@ -209,7 +209,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "add_symlink_in_dir_recursive",
 			args: []string{"/home/user/foo"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				recursive: true,
 			},
 			root: map[string]interface{}{
@@ -270,7 +270,7 @@ func TestAddCommand(t *testing.T) {
 		{
 			name: "dont_add_ignored_file_recursive",
 			args: []string{"/home/user/foo"},
-			add: addCommandConfig{
+			add: addCmdConfig{
 				recursive: true,
 			},
 			root: map[string]interface{}{
@@ -318,8 +318,8 @@ func TestAddCommand(t *testing.T) {
 			if err != nil {
 				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 			}
-			if err := c.runAddCommand(fs, tc.args); err != nil {
-				t.Errorf("c.runAddCommand(fs, nil, %+v) == %v, want <nil>", tc.args, err)
+			if err := c.runAddCmd(fs, tc.args); err != nil {
+				t.Errorf("c.runAddCmd(fs, nil, %+v) == %v, want <nil>", tc.args, err)
 			}
 			vfst.RunTests(t, fs, "", tc.tests)
 		})
diff --git a/cmd/chattr_test.go b/cmd/chattr_test.go
index 3478894df..2227b4256 100644
--- a/cmd/chattr_test.go
+++ b/cmd/chattr_test.go
@@ -295,8 +295,8 @@ func TestChattrCommand(t *testing.T) {
 				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 			}
 			defer cleanup()
-			if err := c.runChattrCommand(fs, tc.args); err != nil {
-				t.Errorf("c.runChattrCommand(fs, nil, %+v) == %v, want <nil>", tc.args, err)
+			if err := c.runChattrCmd(fs, tc.args); err != nil {
+				t.Errorf("c.runChattrCmd(fs, nil, %+v) == %v, want <nil>", tc.args, err)
 			}
 			vfst.RunTests(t, fs, "", tc.tests)
 		})
diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go
index b30521742..d5ed6e9ad 100644
--- a/cmd/cmd_test.go
+++ b/cmd/cmd_test.go
@@ -32,8 +32,8 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi add ~/.bashrc
 	t.Run("chezmoi_add_bashrc", func(t *testing.T) {
-		if err := c.runAddCommand(fs, []string{"/home/user/.bashrc"}); err != nil {
-			t.Errorf("c.runAddCommand(...) == %v, want <nil>", err)
+		if err := c.runAddCmd(fs, []string{"/home/user/.bashrc"}); err != nil {
+			t.Errorf("c.runAddCmd(...) == %v, want <nil>", err)
 		}
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi",
@@ -50,8 +50,8 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi forget ~/.bashrc
 	t.Run("chezmoi_forget_bashrc", func(t *testing.T) {
-		if err := c.runForgetCommand(fs, []string{"/home/user/.bashrc"}); err != nil {
-			t.Errorf("c.runForgetCommand(...) == %v, want <nil>", err)
+		if err := c.runForgetCmd(fs, []string{"/home/user/.bashrc"}); err != nil {
+			t.Errorf("c.runForgetCmd(...) == %v, want <nil>", err)
 		}
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi/dot_bashrc",
@@ -63,8 +63,8 @@ func TestExercise(t *testing.T) {
 	// chezmoi add ~/.netrc
 	t.Run("chezmoi_add_netrc", func(t *testing.T) {
 		mustWriteFile("/home/user/.netrc", "# contents of .netrc\n", 0600)
-		if err := c.runAddCommand(fs, []string{"/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runAddCommand(...) == %v, want <nil>", err)
+		if err := c.runAddCmd(fs, []string{"/home/user/.netrc"}); err != nil {
+			t.Errorf("c.runAddCmd(...) == %v, want <nil>", err)
 		}
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi/private_dot_netrc",
@@ -77,8 +77,8 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi chattr -- -private,+empty ~/.netrc
 	t.Run("chezmoi_chattr_netrc", func(t *testing.T) {
-		if err := c.runChattrCommand(fs, []string{"-private,+empty", "/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runChattrCommand(...) == %v, want <nil>", err)
+		if err := c.runChattrCmd(fs, []string{"-private,+empty", "/home/user/.netrc"}); err != nil {
+			t.Errorf("c.runChattrCmd(...) == %v, want <nil>", err)
 		}
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi/empty_dot_netrc",
@@ -91,8 +91,8 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi apply ~/.netrc
 	t.Run("chezmoi_apply_netrc", func(t *testing.T) {
-		if err := c.runApplyCommand(fs, []string{"/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runApplyCommand(...) == %v, want <nil>", err)
+		if err := c.runApplyCmd(fs, []string{"/home/user/.netrc"}); err != nil {
+			t.Errorf("c.runApplyCmd(...) == %v, want <nil>", err)
 		}
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.netrc",
@@ -105,8 +105,8 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi remove ~/.netrc
 	t.Run("chezmoi_remove_netrc", func(t *testing.T) {
-		if err := c.runRemoveCommand(fs, []string{"/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runRemoveCommand(...) == %v, want <nil>", err)
+		if err := c.runRemoveCmd(fs, []string{"/home/user/.netrc"}); err != nil {
+			t.Errorf("c.runRemoveCmd(...) == %v, want <nil>", err)
 		}
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.netrc",