2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

chezmoiでdotfilesを管理したメモ

Posted at

1. インストール

$ brew install chezmoi

2. 初期化

僕はすでにdotfiles用のレポジトリを持っていたので、それを使いました

$ chezmoi init git@github.com:ZOI-dayo/dotfiles.git

3. ファイルのインポート

現時点では、~/.zshrcなどのファイルが他の場所へのシンボリックリンクになっていたので、--followをつけます

$ chezmoi add --follow ~/.zshrc
$ chezmoi add --follow ~/.config/nvim/

# dot_config/nvim/.keep しか生成されなかったので
$ cp -r ~/.config/nvim/* `chezmoi source-path`/dot_config/nvim/
$ rm `chezmoi source-path`/dot_config/nvim/.keep

$ chezmoi add --follow ~/.vimrc

ついでに、元のdotfilesにあったファイルを一時的によけておく

$ chezmoi cd
$ mkdir tmp
$ mv ./.* ./tmp/
$ mv tmp/.git .git
$ mv bash init.vim nvim tmp/

4. 特定のPCでのみ適用される設定を作る

$ chezmoi chattr +template ~/.zshrc

.tmplファイルではいろいろな変数や制御文が使えるので、dot_zshrc.tmplを好きに編集すればよいです

5. chezmoiignoreを整備する

$ chezmoi cd
$ touch .chezmoiignore
$ nvim .chezmoiignore

README.md
LICENSE

6. 適用

$ chezmoi apply

参考記事

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?