[MAC] vi setting , ls color and alias

今天一個下午都一直在練習用command line的方式去設定一些東西,現在來報告一下今天研究的結果:

1. vi setting:
因為之前一直看到很多人在用vi/vim來開發程式,所以一定要來學一下,因為他有很多很方便的功能可以讓我們輕易上手,提供我們更高的便利性去design a program。因為MAC是based on Darwin 而且有部分的東西是從FreeBSD來的,所以設定的方法和他們一樣。

因為我不想要去動到core的資料,所以從flexibility的角度來說,我希望每個設定是獨立且不會受到影響的,而前輩們早就想到這些東西,就提供了一個方法,可以在不同user的家目錄下這個指令:


vi .vimrc

去設定vi提供的一個user defined的檔案,在這個檔案內做設定,像我就設定成這樣:


syntax on
hi Comment ctermfg = Green
set hlsearch
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set cindent
set autoindent
set number

主要是要開啟syntax color,因為打開才看的下去,要不然他原本都是白色的字,看了很難過…我是看不下去啦= =” 所以就改下去了,而hlsearch是對search的結果做highlight的動作,而set number則是顯示行號,其他的就是一些tab寬度、縮排的設定,有需要再自己去找一下相關的設定。

2,3 alias and ls color
alias 在 Yahoo Dictionary 的意思就是:

n. (名詞 noun)
化名;別名
ad. (副詞 adverb)
別名叫;化名為

所以就是可以把已知指令用更簡單的方式來表示,所以我們可以在家目錄找到.profile,就vi它吧!

vi .profile


alias ll="ls -al"
export CLICOLOR=1
export LSCOLORS=dxfxcxdxbxegedabagacad

這邊要注意的就是ailas的等號旁邊是不能有space的,有的話會出問題。而根據FreeBSD `ls’: Colour-coded directory/file listing(s)這篇文章所講的,只要用export CLICOLOR=1,這樣就可以開啟顏色的功能,不過也是可以用 alias ls=”ls -G”,同樣可以達到我們要的效果

The color designators are as follows:
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
Note that the above are standard ANSI colors. The actual display may differ depending
on the color capabilities of the terminal in use.

The order of the attributes are as follows:

1. directory
2. symbolic link
3. socket
4. pipe
5. executable
6. block special
7. character special
8. executable with setuid bit set
9. executable with setgid bit set
10. directory writable to others, with sticky bit
11. directory writable to others, without sticky bit

The default is “exfxcxdxbxegedabagacad”,
for regular directories, black foreground and red background for setuid executables,
etc.

大概就是這樣,看還有想到什麼再來補上!

δ 最新的文章,有為MAC OSX 設計的LS color Picker,有興趣的朋友可以用用看並給我一些建議:P~

Leave a Reply

Your email address will not be published. Required fields are marked *