1. 啟動終端Terminal
2. 進入當前用戶的home目錄
輸入cd ~
3. 創建.bash_profile
輸入touch .bash_profile
在導入並應用完顏色方案之后,通過命令vim ~/.bash_profile 或open ~/.bash_profile編輯文件,添加以下內容,之后source ~/.bash_profile來應用文 件修改。
4. 編輯.bash_profile文件
輸入open -e .bash_profile
CLICOLOR=1 LSCOLORS=gxfxcxdxbxegedabagacad export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ ' export TERM=xterm-color
5. 保存文件,關閉.bash_profile
6. 更新剛配置的環境變量
輸入source .bash_profile
7. 這樣之后ls還是不能顯示顏色,需要指定ls -G才能顯示顏色,這里我們可以為它配置別名,通過命令vim ~/.bashrc或open ~/.bashrc編輯文件,添加以下內容, 之后source ~/.bashrc來應用修改。
alias ll='ls -lG' alias ls='ls -G'
保存后還需對 .bash_profile 進行一些設置。打開 .bash_profile 文件,添加以下內容。
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
