LoginSignup
50
49

More than 1 year has passed since last update.

設定ファイルを複数ファイルに分割して管理する構文のまとめ

Last updated at Posted at 2014-09-12

はじめに

設定ファイルは中身が肥大化してくると,
機能ごとなど, 複数ファイルに分割して管理した方が整理でき, 全体を見通せる.
また, 設定を追記するときも, 追記する場所が自ずと決まり,
中身が段々ぐちゃぐちゃになっていくということも未然に防げる.

Git, SSH, bashやzsh, Vim, Emacsで設定ファイルを分割する例文は以下のとおり.

Git

includeディレクティブを使う.

~/.gitconfig
[include]
    path = .gitconfig.d/user.gitconfig  # userの設定
    path = .gitconfig.d/alias.gitconfig # aliasの設定
    path = .gitconfig.d/diff.gitconfig  # diffの設定

SSH

Includeディレクティブを使う.

~/.ssh/config
Include conf.d/aws.conf     # Amazon EC2などの設定
Include conf.d/vagrant.conf # Vagrantの設定
Include conf.d/home.conf    # 自宅サーバの設定

sh

~/.bashrc
bash_conf=~/.bash/conf

. $bash_conf/alias-init.bash    # aliasの設定
. $bash_conf/function-init.bash # 関数の設定
. $bash_conf/prompt-init.bash   # プロンプトの設定

Vim

sourceを使う.

~/.vimrc
let $VIM_CONF = $HOME . '/.vim/conf'

source $VIM_CONF/bundle-init.vim " NeoBundleの設定
source $VIM_CONF/unite-init.vim  " Uniteの設定

Emacs

$ ls ~/.emacs.d/conf
font-init.el
org-init.el
helm-init.el

上記のように分割ファイルを配置するならば,
下記のようにinit.elに読み込めば良い.

~/.emacs.d/init.el
(add-to-list 'load-path "~/.emacs.d/conf")

(load "font-init") ; フォントの設定
(load "org-init")  ; org-modeの設定
(load "helm-init") ; helmの設定
50
49
2

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
50
49