Macbook——Mac终端Terminal如何修改颜⾊,字体,背景
⼀、修改偏好设置
   打开terminal,左上⾓终端-》偏好设置,打开如下:
   修改完得退出终端(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 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
source ~/.bash_profile
# HomeBrew END
(2)~/.bash_profile
# HomeBrew
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
如何在vim中运行命令#⽩⾊背景⽤以下命令
#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 粗体⿊⾊,通常显⽰为深灰⾊
#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
"      #Created Time:
"      >>>>>###
autocmd BufWritePost MYVIMRCsource MYVIMRC
" 让配置变更⽴即⽣效
Processing math: 100%

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论