.bashrcや.bash_profileにいろいろな設定が混ざっているのが嫌なので、.bashrc
の末尾に以下のようにして設定ファイルを読み込ませるようにする。
...
if[-d"$HOME/.config/bash/rc.d"];then.$HOME/.config/bash/rc.d/*fi
.bash_profile
には以下。必要があれば.profile
の読み込みを先頭でやる。
if[-f"$HOME/.profile"];then."$HOME/.profile"fi
if[-d"$HOME/.config/bash/profile.d"];then.$HOME/.config/bash/profile.d/*fi
あとは設定したディレクトリにスクリプトを置いて再読み込みすればよい。
ファイル名の昇順で読み込まれるので読み込むファイル名は気を付ける。
source ~/.bashrc
おまけ
Ubuntu18.04の.profile
はこのようになっている。
# if running bashif[-n"$BASH_VERSION"];then# include .bashrc if it existsif[-f"$HOME/.bashrc"];then."$HOME/.bashrc"fi
fi# set PATH so it includes user's private bin if it existsif[-d"$HOME/bin"];then
PATH="$HOME/bin:$PATH"fi# set PATH so it includes user's private bin if it existsif[-d"$HOME/.local/bin"];then
PATH="$HOME/.local/bin:$PATH"fi