LoginSignup
0
0

More than 1 year has passed since last update.

Macでbashの設定をターミナル起動時に読み込む設定(.bashrc / .bash_profile)

Posted at

はじめに

2021/08/10時点での記事になります。
最近、ターミナルでコマンドを叩く機会が減ってたのですが、久々実行するとなんとなく違和感を感じました。
いつも ls コマンドを実行するとエイリアスで、 ls -aF としてたのに素の ls コマンドでした。
ということで、いつの間にかターミナル起動時に .bashrc が自動的に読み込まれなくなっていました。

そこでの解決策をここで書いていきます。

スペック

mac OS Big Sur / Ver11.4

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
Copyright (C) 2007 Free Software Foundation, Inc.

やること

やることは一つだけで、 .bash_profile を作成して、おまじないを書けば完了

1. まずはターミナルを開きます。
2. その後、 .bash_profile を開きます。

$ vi ~/.bash_profile

3. 以下のおまじないを書いて保存すれば完了です。

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

さいごに

最近では zsh をデフォルトのシェルとして利用してくださいねと注意書きがされています。

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

でも、もう少し bash を使っていきたい(PCを買い換えるまでは)です。

0
0
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
0
0