https://github.com/10sr/dotfiles
Porpose
設定を書く場所を集約したい
Problem
例えば、 .profile
に何かを書いたとして、その後 .bash_profile
が生成された場合、 bash
起動時に .profile
は読まれなくなってしまう、みたいな。
.bashrc を .bash_profile から読むか .profile から読むか?
What Should I Do?
.profile
: ログイン設定.bash_profile
: bash 固有のログイン設定.profile
を読むべき- ログイン時には
.bash_profile
が読まれ、.bashrc
は読まれない.bashrc_profile
は explicit に.bashrc
を読むべき
.shrc
: 対話シェル用の設定.bashrc
: bash 用の対話シェル設定.shrc
を読むべき
Sourcing Flow
$HOME/{.bash_profile,.zprofile} <= login with bash/zsh
| |
`---$HOME/.profile <= login with sh
| |
`---|--$HOME/.{ba,z}shrc <= bash, zsh
| |
`--`--$HOME/.shrc <= sh (by EnvVal ENV)
* .profile should load .shrc unless bash nor zsh is working
-
Login with sh
- .profile
- .shrc
-
Login with bash
- .bash_profile
- .profile
- .bashrc (from .bash_profile)
- .shrc
-
Non-login with bash
- .bashrc
- .shrc
So, What Should I Have?
-
.profile
- General setups for login
- 環境変数など
-
.bash_profile
- bash-specific setups for login
- なんだろう? bash 固有で使いたい環境変数とか
. ~/.profile || true
. ~/.bashrc || true
-
.shrc
- General setups for interactive shell
- よくやるやつ。関数とか alias とか
-
.bashrc
- bash-specific setups for interactive shell
- bash 固有の alias とか補完とか
. ~/.shrc || true
For Example
bash を使ってる時、
.bash_profile
に. ~/.profile
.bash_profile
に. ~/.bashrc
.bashrc
に. ~/.shrc