Skip to content

Commit

Permalink
Add how to for using chezmoi with brew bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed May 13, 2021
1 parent 883a5f0 commit 2b546b7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
* [Understand how scripts work](#understand-how-scripts-work)
* [Install packages with scripts](#install-packages-with-scripts)
* [Use chezmoi with GitHub Codespaces, Visual Studio Codespaces, Visual Studio Code Remote - Containers](#use-chezmoi-with-github-codespaces-visual-studio-codespaces-visual-studio-code-remote---containers)
* [Use chezmoi on macOS](#use-chezmoi-on-macos)
* [Use `brew bundle` to manage your brews and casks](#use-brew-bundle-to-manage-your-brews-and-casks)
* [Use chezmoi on Windows](#use-chezmoi-on-windows)
* [Detect Windows Subsystem for Linux (WSL)](#detect-windows-subsystem-for-linux-wsl)
* [Run a PowerShell script as admin on Windows](#run-a-powershell-script-as-admin-on-windows)
Expand Down Expand Up @@ -1011,6 +1013,30 @@ sudo apt install -y vim-gtk
{{- end -}}
```

## Use chezmoi on macOS

### Use `brew bundle` to manage your brews and casks

Homebrew's [`brew bundle`
subcommand](https://docs.brew.sh/Manpage#bundle-subcommand) allows you to
specify a list of brews and casks to be installed. You can integrate this with
chezmoi by creating a `run_once_` script. For example, create a file in your
source directory called `run_once_before_install-packages-darwin.sh.tmpl`
containing:

{{- if (eq .chezmoi.os "darwin") -}}
#!/bin/bash

brew bundle --no-lock --file=/dev/stdin <<EOF

This comment has been minimized.

Copy link
@felipecrs

felipecrs May 27, 2021

Contributor

This could be simplified to:

- brew bundle --no-lock --file=/dev/stdin <<EOF
+ brew bundle --no-lock --file=- <<EOF
brew "git"
cask "google-chrome"
EOF
{{ end -}}

Note that the `Brewfile` is embedded directly in the script with a bash here
document. chezmoi will run this script whenever its contents change, i.e. when
you add or remove brews or casks.

## Use chezmoi on Windows


Expand Down

0 comments on commit 2b546b7

Please sign in to comment.