7
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

この記事では、Mac の開発環境を Brewfileを使ってコード化し、どの端末でも同じ環境を一瞬で再現できる方法をまとめます。難しいツールは使わず、シンプルに手動管理しながら育てていける構成です。

1. リポジトリを作る

dotfileっていうリポジトリを作ってください。

git clone https://github.com/you/dotfiles ~/dotfiles
cd ~/dotfiles

2. 今の環境を Brewfile に書き出す

まずは、現在の Homebrew 環境を Brewfile として書き出します。

brew bundle dump --file=~/Brewfile 

これで、インストールされている brew / cask 一覧が ~/Brewfile に出力されます。

dotfiles に取り込む

cd ~/dotfiles
cat ~/Brewfile > ./Brewfile

2..zshrcを書き出す

cp ~/.zshrc ~/dotfiles/

4. install.sh を作る

新しい Mac をセットアップするときに使う install.sh を dotfiles に置きます。

#!/bin/bash

# Homebrew のインストール
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Brewfile の内容をまとめてインストール
brew bundle --file=./Brewfile

# zshrcを取り込む
cat ~/dotfiles/.zshrc > ~/.zshrc

実行例:

git clone https://github.com/you/dotfiles ~/dotfiles
cd ~/dotfiles
bash install.sh

6. Git に乗せて完成

cd ~/dotfiles
git add .
git commit -m "Add Brewfile and zsh dotfiles"
git remote add origin git@github.com:yourname/dotfiles.git
git push -u origin main

新しい Mac では install.sh を叩くだけで Brew の環境が復元され、.zshrc から dotfiles が読み込まれるようになります。

まとめ

dotfiles と .zshrc を使った、いちばん手軽で始めやすい環境構築方法です。
面倒な仕組みを使わずにサクッと自分だけの環境を作れるので、ぜひ試してみてください!

7
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?