Mac——Mac終端Terminal如何修改顏色,字體,背景


 

一、修改偏好設置


    打開terminal,左上角終端-》偏好設置,打開如下:
    Mac終端Terminal如何修改顏色,字體,背景
  
   點擊“Profiles”——》左側列表中選擇喜歡的樣式——》點擊“Default”,如下圖:

   修改完得退出終端(command + q),重新打開才能生效

   END

二、偏好設置里設置的字體顏色是指所有的字體的顏色,如果希望不同文件用不同顏色顯示,需執行以下操作  

 

   進入~目錄。 $ cd ~ 

   編輯.bash_profile配置文件。 $ vim .bash_profile

     輸入i(英文輸入狀態下),進入編輯狀態

   編輯好,按Ese,然后按:wq(英文輸入狀態),保存並退出

   讓設置生效,輸入 $ source .bash_profile

   查看設置效果 $ ls 

   END
   PS:我的在運行了$ source .bash_profile,之后,依然沒有改變顯示;
      mac跟linux/unix的操作命令同屬一族,很多地方相似,比如都存在:~/.bash_profile
                                     ~/.bashrc          #這個我沒有找到 
      
      mac的默認terminal是zsh,其也有一個對應的文件 ~/.zshrc,這個文件是每次打開terminal都會執行的,但前兩者則不然;
      但我們一般在前兩者中設置alias(其實在/zshrc中設置也可以)以及文件夾和目錄顏色設置等,如果要保證設置在每次打開terminal時都會生效,
      我們可以在.zshrc中添加source ~/.bashrc或者source ~/.bash_profile
   PS:放上我的 ~/.zshrc和~/.bash_profile文件,如下:
     

(1)~/.zshrc:
# HomeBrew

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

export PATH="/usr/local/bin:$PATH"

export PATH="/usr/local/sbin:$PATH"

export PATH=/Users/mayl/Library/Python/3.8/bin/:$PATH

export PATH=/bin:/usr/bin:/usr/local/bin:${PATH}

#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #load RVM into a shell session *as a function*

export PS1='%n@%m %1~ %#' #%n 當前用戶的賬號名稱

export LS_OPTIONS='--color=auto' #如果沒有指定,則自動選擇顏色

export CLICOLOR='Yes' #是否輸出顏色

export LSCOLORS='CxfxcxdxbxegedabagGxGx' #指定顏色

 

#grep

alias grep='grep --color=always'

#ls

alias ll='ls -l'

source ~/.bash_profile 

# HomeBrew END

 

(2)~/.bash_profile

# HomeBrew

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

export PATH="/usr/local/bin:$PATH"

export PATH="/usr/local/sbin:$PATH"

export PATH="/Users/mayl/Library/Python/3.8/bin"

export PATH=/bin:/usr/bin:/usr/local/bin:${PATH}

#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #load RVM into a shell session *as a function*

export PS1='%n@%m %1~ %#' #%n 當前用戶的賬號名稱

export LS_OPTIONS='--color=auto' #如果沒有指定,則自動選擇顏色

export CLICOLOR='Yes' #是否輸出顏色

export LSCOLORS='CxfxcxdxbxegedabagGxGx' #指定顏色

 

#grep

alias grep='grep --color=always'

#ls

alias ll='ls -l'

 

#for color

#export CLICOLOR=1

#黑色背景用以下命令

#export LSCOLORS=GxFxCxDxBxegedabagaced

#export LSCOLORS=GaFaCaDaBaegedabagaced

#白色背景用以下命令

#export LSCOLORS=ExFxBxDxCxegedabagacad

#終端默認顏色 exfxcxdxbxegedabagacad

#下面給出的各個字母代表指代的不同顏色

#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

 

# HomeBrew END

 

三、設置vim顏色(vim指令編輯文件的模式顯示效果) 

    進入~目錄。 $ cd ~

    復制系統的vim配置文件到用戶目錄 $ cp -r /usr/share/vim/vimrc ~/.vimrc

    編輯.vimrc文件配置我們的vim設置,有很多配置,只提供目前自己在用的一個配置 $ vim .vimrc

    配置好,按Esc,然后輸入:wq(英文輸入狀態)保存並退出 再輸入 $ vim .vimrc 可以查看設置效果
    PS: 放一下我的~/.vimrc文件
      

 

" Configuration file for vim

set modelines=0     " CVE-2007-2438

 

" Normally we use vim-extensions. If you want true vi-compatibility

" remove change the following statements

set nocompatible    " Use Vim defaults instead of 100% vi compatibility

set backspace=2     " more powerful backspacing

 

" Don't write backup file if vim is being called by "crontab -e"

au BufWrite /private/tmp/crontab.* set nowritebackup nobackup

" Don't write backup file if vim is being called by "chpass"

au BufWrite /private/etc/pw.* set nowritebackup nobackup

 

let skip_defaults_vim=1

 

" 上邊是原來文件自帶的,下邊是自己添加的

 

syntax on

" 語法高亮

 

autocmd InsertLeave * se nocul

autocmd InsertEnter * se cul

" 用淺色高亮當前行

 

set tabstop=4

" Tab鍵的寬度

 

set softtabstop=4

set shiftwidth=4

" 統一縮進為4

 

set number

" 顯示行號

 

colorscheme pablo

" 設置顏色主題,主題在/usr/share/vim/vim81/colors目錄下

 

set ruler

" 在編輯過程中,在右下角顯示光標位置的狀態行

 

set completeopt=preview,menu

" 代碼補全

 

set scrolloff=3

" 光標移動到buffer的頂部和底部時保持3距離

 

set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ Ln\ %l,\ Col\ %c/%L%)

" 設置在狀態行顯示的信息

 

au BufReadPost * if line("'\"") > 0 | if line("'\"") <= line("$") | exe("norm '\"") | else |exe "norm $"| endif | endif

" 設置vim打開文件時光標在上次退出位置

 

"auto add pyhton header --start

autocmd BufNewFile *.py 0r ~/.vim/vim_template/vim_pyhton_header

autocmd BufNewFile *.py ks|call FileName()|'s

autocmd BufNewFile *.py ks|call CreatedTime()|'s

fun FileName()

    if line("$") > 10

        let l = 10  "這里是字母L 不是數字1 

    else

        let l = line("$")

    endif

    exe "1," . l . "g/File Name:.*/s/File Name:.*/File Name: " .expand("%")

       "最前面是數字1,這里的File Name: 要和模板中一致

endfun

fun CreatedTime()

    if line("$") > 10

        let l = 10

    else

        let l = line("$")

    endif

    exe "1," . l . "g/Created Time:.*/s/Created Time:.*/Created Time: " .strftime("%Y-%m-%d %T")

        "這里Create Time: 要和模板中一致

endfun

"auto add python header --end  

"[Vim]新建python文件自動添加python header

" ~/.vim/vim_template/vim_pyhton_header  需要提前創建好,內容如下:

"       #!/usr/bin/python

"       #-*- coding:utf-8 -*-

"       ############################

"       #File Name:

"       #Author: mayl

"       #Mail: 839365149@qq.com

"       #Created Time:

"       ############################

 

autocmd BufWritePost $MYVIMRC source $MYVIMRC

" 讓配置變更立即生效

 

 

 



參考:https://jingyan.baidu.com/article/ce43664948bd093772afd373.html

https://blog.csdn.net/orangleliu/article/details/41902851


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM