LoginSignup
4
1

More than 3 years have passed since last update.

git-bashでaliasを使うために.bashrcを作成

Posted at

git-bashでもよく使うコマンドをalias化しておこうと思ったものの
ホームディレクトリに.bashrc .bash_profile などのファイルが存在しない

.bashrc を作成

touch ~/.bashrc

git-bashを起動すると以下のメッセージが表示される

WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.

This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be created for you.

~/.bashrcが見つかったけど、~/.bash_profile などが見つからないので
~/.bashfileを読み込む~/.bash_profileをあなたのために作っておきました

という感じの内容で、以下のファイルが生成されていた。

$ cat ~/.bash_profile
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc

手持ちの書籍「新しいLinuxの教科書」によると、
bashの設定ファイル読み込み順序は以下のようになっているらしい

ログインシェルとして起動

/etc/profileを読み込む
↓
~/.bash_profileを読み込む
↓
~/.bashrcを読み込む(設定になっていることが多い)

非ログインシェルとして起動

~/.bashrcを読み込む

git-bashでもこの作法にのっとった感じに~/.bash_profile を作成してくれるということだろうか

4
1
0

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
4
1