LoginSignup
6
1

More than 3 years have passed since last update.

bashとcurlで実現する初めてのdotfiles

Last updated at Posted at 2019-12-15

自分のdotfilesをちゃんと整理したいと思っていて、この週末にやっと作業したので、共有したいと思います。

下調べ

世の中には、どんなdotfiles管理手法があるのかあるのか調べました。
pythonスクリプトやrubyなど、言語も様々で、
リンクするか、コピーするか等、ファイルの配置方法も色々あることがわかりました。

私としては、最小構成のサーバーに対しても、すぐにdotfilesを展開できるような仕組みを作りたかったので、以下の方針で自分のdotfilesを整備することを考えました。

方針

  • できるだけシンプルな構成にする
  • bashだけでできる

参考にした記事、レポジトリ

以下の記事が共感でき、一番参考になりました。

作業

  • b4b4r07さんとyutalatayさんのinstallスクリプトを参考にして、以下の機能をもつスクリプトを作成しました
--- a/yutakatay/dotfiles-mini/.bin/dotsinstall.sh
+++ b/hnishi/dotfiles/scripts/install.sh
@@ -19,7 +19,7 @@ link_to_homedir() {
   fi

   local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-  local dotdir=$(readlink -f ${script_dir}/..)
+  local dotdir=$(dirname ${script_dir})
   if [[ "$HOME" != "$dotdir" ]];then
     for f in $dotdir/.??*; do
       [[ `basename $f` == ".git" ]] && continue
  • ワンラインのコマンド一発で、ダウンロードとインストールを行えるようにしました
curl -L raw.githubusercontent.com/hnishi/dotfiles/master/scripts/download.sh | bash
  • scriptsというディレクトリ名は、私の好みでつけました
  • できたdotfilesはこちら。
  • bashとcurlがあればワンコマンドでinstallできるdotfilesが完成しました

今後の展望

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