Help us understand the problem. What is going on with this article?

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

はじめに

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

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

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の設定

Vim

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

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

sh

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

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

SSH

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

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

Git

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

~/.gitconfig
[include]
    path = .gitconfig.d/user.gitconfig  # userの設定
    path = .gitconfig.d/alias.gitconfig # aliasの設定
    path = .gitconfig.d/diff.gitconfig  # diffの設定
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away