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