iTerm2 顏色生效配置

iTerm2 顏色生效配置

bash設置

在導入並應用完顏色方案以後,經過命令vim ~/.bash_profileopen ~/.bash_profile編輯文件,添加如下內容,以後source ~/.bash_profile來應用文件修改。git

CLICOLOR=1
LSCOLORS=gxfxcxdxbxegedabagacad
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ '
export TERM=xterm-color

這樣以後ls仍是不能顯示顏色,須要指定ls -G才能顯示顏色,這裏咱們能夠爲它配置別名,經過命令vim ~/.bashrcopen ~/.bashrc編輯文件,添加如下內容,以後source ~/.bashrc來應用修改。github

alias ll='ls -lG'
alias ls='ls -G'

保存後還需對 .bash_profile 進行一些設置。打開 .bash_profile 文件,添加如下內容。shell

if [ -f ~/.bashrc ]; then
      source ~/.bashrc
fi

緣由是對於Mac系統,每次開機運行時是執行 .bash_profile 文件,而不會執行 .bashrc 文件,因此在 .bash_profile 文件中添加上述內容,讓Mac在執行 .bash_profile 時讓 .bashrc 文件生效。vim

zsh設置

或者直接將shell改成zsh,即可以直接使用對應的配色了bash

  • 克隆這個項目到本地(前提是你得有裝git)code

    git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zshit

  • 建立一個zsh的配置文件 注意:若是你已經有一個~/.zshrc文件的話,建議你先作備份。使用如下命令zsh

    cp ~/.zshrc ~/.zshrc.orig配置

    而後開始建立zsh的配置文件file

    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

  • 設置zsh爲你的默認的shell

    chsh -s /bin/zsh

  • 重啓並開始使用你的zsh (打開一個新的終端窗口即可…)

至此,大功告成。

經過vim ~/.zshrc 來編輯你的配置文件,例如把(~/.bash_prorile或者~/.profile等)給拷貝到zsh的配置文件~/.zshrc裏,由於zsh兼容bash,因此你大可放心把bash的配置粘貼到~/.zshrc底部即可。

相關文章
相關標籤/搜索