2019年4月17日 星期三

讓MAC下的終端機bash有顏色




用編輯器打開 ~/.profile
加入
export CLICOLOR="true"
export LSCOLORS="gxfxcxdxcxegedabagacad"
export PS1="\[\e[0;31m\]\u@\[\e[m\e[0;34m\]\h\[\e[m \e[0;32m\]\W >\[\e[m\]"

LSCOLORS 的字串設定順序:

directory
symbolic link
socket
pipe
executable
block special
character special
executable with setuid bit set
executable with setgid bit set
directory writable to others, with sticky bit
directory writable to others, without sticky bit

顏色的對應值:
a -> black
b -> red
c -> green
d -> brown
e -> blue
f -> magenta
g -> cyan
h -> light grey

A -> bold black, usually shows up as dark grey
B -> bold red
C -> bold green
D -> bold brown, usually shows up as yellow
E -> bold blue
F -> bold magenta
G -> bold cyan
H -> bold light grey; looks like bright white
x -> default foreground or background

每個檔案型態有兩個值,前景色和背景色。

以LSCOLORS="gxfxcxdxcxegedabagacad" 做說明,前面的 gx 是設定資料夾顯示的顏色為青色(cyan),底色是預設的前景和背景色;fx
是 symbolic link 的設定,顯示的字是洋紅(magenta),底色是預設的前景和背景色,依此類推。

若希望自已修改,又不想一個字一個字輸入,網路上有小工具,直接用 GUI 設定和預覽,設定好想要的顏色之後,就產生設定字串出來啦。

website: http://geoff.greer.fm/lscolors/

沒有留言:

Free ERP on the Raspberry Pi (odoo)

  #更新系統軟體 sudo apt update && sudo apt upgrade -y #安裝資料庫 sudo apt install postgresql -y #安裝py程序 sudo apt install python3-pip -y #安裝od...