쿼카러버의 기술 블로그

[MAC] 터미널 켤 때 bash_profile 내용 자동 적용하는 법 (run ~/.bash_profile when terminal start up) 본문

Short Commands

[MAC] 터미널 켤 때 bash_profile 내용 자동 적용하는 법 (run ~/.bash_profile when terminal start up)

quokkalover 2021. 7. 20. 10:42

bash_profile을 열심히 수정해도 터미널을 막상 시작하면 바로 적용이 안되는 경우가 있다.

그럴 때는

 

1) bash_profile에 아래 라인을 추가한다해주면 된다

[[ -s ~/.bashrc ]] && source ~/.bashrc

2)  iTerm의 Preference - Profile - General의 Command부분이 Login Shell인지 확인해야 한다.

 

3) 아래 커맨드 입력

echo "source ~/.bash_profile" >> ~/.zshrc

새로은 Mac OS는 default로 Zsh를 사용하고 있는데

zsh는 켜질 때  ~/.zshrc를 찾기 때문에 bash_profile의 내용을 sourcing 하기 위해서는 위 커맨드를 실행해서

zsh를 실행할 때 source ~/.bash_profile을 실행하게 하는 것이다.

 

이렇게 하고나면 이제 bash_profile의 세팅이 터미널 실행할 때마다 적용되는걸 확인할 수 있다. 

Comments