Last active
April 27, 2018 05:50
-
-
Save githiro/45f4bf746e2745f71e543eedebd5a6ca to your computer and use it in GitHub Desktop.
Bash: Bash profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PS1 | |
export PS1="\t \W \\$ " | |
# Read "~/.bashrc". ".bashrc" is only read by a shell that's both interactive and non-login | |
test -r ~/.bashrc && . ~/.bashrc |
bash_profile
.bash_profile はログイン時にのみ実行されます。具体的な用途は:
- 環境変数を設定する (export する変数)
- 環境変数はプロセス間で勝手に受け継がれるのでログイン時のみ設定すれば十分です。
.bashrc
.bashrc は対話モードの bash を起動する時に毎回実行されます。具体的な用途は:
- 環境変数でない変数を設定する (export しない変数)
- エイリアスを定義する
- シェル関数を定義する
- コマンドライン補完の設定をする
これらは bash を起動する度に毎回設定する必要があるものです。
以下より引用: https://qiita.com/magicant/items/d3bb7ea1192e63fba850
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
これを~/.bash_profileに設定することで、macOSのターミナルで$マークの前に毎回表示される、コンピュータ名やユーザー名など長ったらしい記述を以下のようにできる。
19:57:21 ~ $
参考:https://qiita.com/tonkotsuboy_com/items/b752a86cee7eaedf28da
Easy Bash Prompt Generator:http://ezprompt.net/