LoginSignup
0
1

More than 5 years have passed since last update.

[小技] dotfilesの変更差分を自動でコミットする

Last updated at Posted at 2017-06-29

複数のマシン上で同じシェル環境を整えるためにGitでdotfilesを管理している方は多いと思いますが、変更するたびにコミット&プッシュを手動で行うのは面倒だと思ったので改善したメモ。

スクリプトの準備

auto-commit.zsh
#!/usr/bin/env zsh

git add -A .
local timestamp="$(date '+%Y/%m/%d %H:%M:%S')"
git commit -m "Automatically updated on ${timestamp}" && git push origin master
chmod +x auto-commit.zsh

几帳面な人はコミット前にスモークテストを挟んでもいいかもしれない。

定期アップデートの設定

cronを使って定期アップデートを設定する。

crontab -e

下記は毎日15時にdotfilesの変更差分があればリモートに反映する例である。

0 15 * * * cd ~/dotfiles && ./auto-commit.zsh
0
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
0
1