はじめに
hkob の雑記録の第11回目は、Homebrew による GUI アプリと UNIX tools のインストールを解説記事を執筆しています。
Brewfile の作成
Homebrew は brew コマンドで簡単にアプリをインストールできるコマンドです。ただし、マシンを入れ替えるたびにコマンドをタイプしまくるのは面倒なので、Brewfile で管理するようにさせています。そのための Brewfile を最初に作成します。
touch Brewfile
この Brewfile を使ってコマンドをインストールする処理を bootstrap.sh に追加します。これもまだエディタがないので、 cat >> で追記します。追加する内容は以下のとおりです。
# homebrew, cask and mas brew bundle -v
bootstrap を実行すると core と cask の tap が自動で取り込まれました。
% ./bootstrap.sh ==> Auto-updating Homebrew... Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). ==> Homebrew collects anonymous analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics No analytics have been recorded yet (nor will be during this `brew` run). ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask). ==> New Formulae netatalk ==> New Casks satdump /opt/homebrew/bin/brew tap homebrew/bundle ==> Tapping homebrew/bundle Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-bundle'... remote: Enumerating objects: 8966, done. remote: Counting objects: 100% (71/71), done. remote: Compressing objects: 100% (49/49), done. remote: Total 8966 (delta 28), reused 34 (delta 21), pack-reused 8895 (from 2) Receiving objects: 100% (8966/8966), 2.28 MiB | 1.77 MiB/s, done. Resolving deltas: 100% (5121/5121), done. Tapped 2 commands (109 files, 2.7MB). Homebrew Bundle complete! 0 Brewfile dependencies now installed.
services のタップも欲しいので、Brewfile に以下のものを追記します。
### tap tap "homebrew/bundle" # brew bundle コマンド tap "homebrew/services" # brew service コマンド
VSCode のインストール
何はともかくエディタを入れたいので、VSCode をインストールします。まずキーワードを知りたいので、brew search で調べます。visual-studio-code がキーワードでした。こちらは Casks の中に入っています。Cask とは Homebrew の GUI アプリのインストーラです。以前は brew cask のようにインストールしましたが、今は brew だけで大丈夫です。
% brew search "visual studio code" ==> Casks visual-studio-code visual-studio-code@insiders
もう少し詳しい情報を知りたいので、 brew info で調べます。
% brew info visual-studio-code ==> visual-studio-code: 1.96.2 (auto_updates) https://code.visualstudio.com/ Not installed From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/v/visual-studio-code.rb ==> Names Microsoft Visual Studio Code VS Code ==> Description Open-source code editor ==> Artifacts Visual Studio Code.app (App) /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code (Binary) ==> Analytics install: 26,837 (30 days), 81,630 (90 days), 328,493 (365 days)
これだけよさそうなので、これを Brewfile に追記します。コマンドは brew でよいのですが、Brewfile では brew と cask は区別します。私はコメントの部分は brew info の Description をそのまま書くことが多いです。
### Casks cask "visual-studio-code" # Open-source code editor
あとは bootstrap を実行するだけです。
% ./bootstrap.sh Skipping install of homebrew/bundle tap. It is already installed. Using homebrew/bundle Skipping install of homebrew/services tap. It is already installed. Using homebrew/services Installing visual-studio-code Installing visual-studio-code cask. It is not currently installed. ==> Downloading https://update.code.visualstudio.com/1.96.2/darwin-arm64/stable ==> Downloading from https://vscode.download.prss.microsoft.com/dbazure/downloa ######################################################################## 100.0% ==> Installing Cask visual-studio-code ==> Moving App 'Visual Studio Code.app' to '/Applications/Visual Studio Code.ap ==> Linking Binary 'code' to '/opt/homebrew/bin/code' 🍺 visual-studio-code was successfully installed! Homebrew Bundle complete! 3 Brewfile dependencies now installed.
さらにこのあとは VSCode の使い方を解説し、UNIX 系ツールのインストールを解説しています。
おわりに
Brewfile を使うことで、インストールするソフトウェアもテキストで記述できるようになりました。
https://hkob.notion.site/hkob-16dd8e4e98ab807cbe3cf3cc94cdfe0f?pvs=4