Mac Mini M4的首次上手配置记录

Page content

硬件清单

* Mac mini M4 钙版 512G
* Acer OKR 130键盘/68键
* Redmi R27 2K 显示器
* 罗技G304 无线鼠标

硬件相关配置和说明

外接键盘适配

acer okr130

不同厂商的键盘,功能设计略有不同,但是基本大同小异,厂商也会提供购买型号的组合键功能说明。

这里需要注意的是:

  • 购买键盘时一定认准是支持win/mac双系统的键盘,这个很重要.

  • 支持有线连接的三模键盘,mac mini m4 初始化的时候需要有线键盘配合完成初始化配置。除非你还有其他备用的有线键盘,且能连接到mac mini m4的type c接口上,再考虑靠谱的无线键盘。

这里只列出ork130/68键 键盘的一些常用组合摁键功能:

Fn + A  切换到win键盘模式
Fn + S  切换到mac键盘模式

Fn + Q  屏幕亮度-
Fn + W  屏幕亮度+

Fn + I  静音
Fn + O  音量-
Fn + P  音量+

显示器屏幕亮度调整

monitor

之前一直在用mbp,所以即使外接显示器,也是可以直接通过键盘来控制屏幕亮暗度的,但是到了mac mini m4这里就行不通了。 当 Mac Mini 连接外置显示器时,默认情况下,调节外接显示器的亮度、声音、对比度等,需通过显示器自身的按钮,颇为不便。而安装开源免费软件 monitorcontrol 后,即可直接通过 Mac 的键盘或系统菜单来调节外接显示器亮度 。

对于程序员来说一些常用开发环境的配置

Homebrew 配置

 1# 可以将如下几个环境变量配置到.zshrc环境变量管理文件中。
 2$ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
 3$ export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
 4$ export HOMEBREW_INSTALL_FROM_API=1
 5
 6$ git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
 7$ /bin/bash brew-install/install.sh
 8
 9# 顺带安装一些常用命令安装包
10$ brew install curl jq tree

ohmyzsh 配置

 1$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
 2# 如果在大陆,可以执行如下命令下载安装脚本
 3$ sh -c "$(curl -fsSL https://install.ohmyz.sh/)"
 4
 5$ brew install autojump
 6
 7$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
 8    ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
 9$ git clone https://github.com/zsh-users/zsh-autosuggestions \
10    ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
11
12$ vim ~/.zshrc
13# 设置主题样式
14ZSH_THEME="robbyrussell"
15# 配置增强插件
16plugins=(
17  dotenv
18  git
19  extract
20  autojump
21  screen
22  urltools
23  zsh-autosuggestions
24  zsh-syntax-highlighting
25  history-substring-search
26)

mysql相关的环境变量配置

这里配置mysql环境主要是为了django开发做准备。

办法一(基于homebrew 包管理):

1$ brew install mysql-client pkg-config
2
3$ export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"
4$ export LDFLAGS="-L/opt/homebrew/opt/mysql-client/lib"
5$ export CPPFLAGS="-I/opt/homebrew/opt/mysql-client/include"
6$ export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"  # <- No need MySQL install.

办法二: 从mysql官网下载mysql / mysql-8.4.5-macos15-arm64.dmg安装包,选择一键部署安装mysql。如按照此办法安装,mysql相关的程序文件将会存储在/usr/local/mysql,接下来我们只需要库文件路径依赖暴露到系统环境变量即可。

1$ export MYSQLCLIENT_CFLAGS="-I/usr/local/mysql/include"
2$ export MYSQLCLIENT_LDFLAGS="-L/usr/local/mysql/lib -lmysqlclient"

配置rust 程序初始化环境相关

1# Rustup,切换到中国大陆源
2$ export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup
3$ export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
4$ export CARGO_HOME="$HOME/.cargo"
5
6# 执行此命令安装
7$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

配置vim个性化配置

vimrc settings

  1set nocompatible
  2filetype off
  3
  4"set rtp+=~/.vim/bundle/Vundle.vim
  5"call vundle#begin()
  6"Plugin 'tpope/vim-fugitive'
  7""Plugin 'fisadev/vim-isort'
  8"Plugin 'mattn/emmet-vim'
  9"Plugin 'airblade/vim-gitgutter'
 10""Plugin 'fatih/vim-go'
 11"Plugin 'vim-scripts/indentpython.vim'
 12"Plugin 'jiangmiao/auto-pairs'
 13"call vundle#end()
 14filetype plugin indent on
 15syntax on
 16
 17" Items set
 18set nu
 19set nostartofline
 20set ruler
 21set nofixendofline
 22set shortmess=atI
 23set laststatus=2
 24set cmdheight=2
 25set scrolloff=3
 26set backspace=indent,eol,start
 27set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
 28set fileencoding=utf-8
 29set termencoding=utf-8
 30set encoding=utf-8
 31set nopaste
 32set title
 33set matchtime=5
 34set hlsearch
 35set incsearch
 36set ignorecase
 37set autoread
 38set ve=block
 39set completeopt=longest,menu
 40set background=light
 41set mouse=a
 42set scroll=3
 43
 44" Optimize for fast terminal connections
 45set ttyfast
 46
 47" Tab set
 48set tabstop=4
 49set shiftwidth=4
 50set softtabstop=4
 51set expandtab
 52set smarttab
 53set list
 54set listchars=tab:\-\ ,nbsp:%,trail 55
 56" Line set
 57set modeline
 58set modelines=4
 59set linebreak
 60set textwidth=80
 61set iskeyword+=_,$,@,%,#,-
 62set nowrap
 63set tabpagemax=15
 64set showtabline=2
 65set showcmd
 66set showmatch
 67set cursorline
 68
 69autocmd BufNewFile * normal G
 70autocmd BufWritePre *.jenkinsfile,*.h,*.c,*.java,*.rb,*.pl,*.py,*.rs :%s/\s\+$//e
 71
 72set nobinary
 73set noeol
 74" Centralize backups, swapfiles and undo history
 75set backupdir=~/.vim/backups
 76set directory=~/.vim/swaps
 77
 78if &term =~ '256color'
 79  set t_Co=256
 80endif
 81
 82if exists("&undodir")
 83    set undodir=~/.vim/undo
 84endif
 85
 86" Use relative line numbers
 87set number relativenumber
 88augroup numbertoggle
 89    autocmd!
 90    autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
 91    autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber
 92augroup END
 93
 94" Uncomment the following to have Vim jump to the last position when
 95" reopening a file
 96if has("autocmd")
 97  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
 98endif
 99
100" Strip trailing whitespace (,ss)
101function! StripWhitespace()
102    let save_cursor = getpos(".")
103    let old_query = getreg('/')
104    :%s/\s\+$//e
105    call setpos('.', save_cursor)
106    call setreg('/', old_query)
107endfunction
108
109"" Git Gutter set
110"let g:gitgutter_diff_args = '-w'
111"let g:gitgutter_signs = 1
112
113" Color terminal definitions set
114hi VertSplit ctermfg=darkgrey ctermbg=NONE cterm=NONE
115hi LineNr ctermfg=darkgrey ctermbg=NONE
116hi NonText cterm=bold ctermfg=darkgrey
117hi Directory ctermfg=darkcyan
118hi WildMenu ctermfg=0 ctermbg=3
119hi Directory ctermfg=darkcyan
120hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
121hi IncSearch ctermfg=black ctermbg=darkgreen cterm=NONE
122hi Search ctermfg=black ctermbg=darkyellow cterm=NONE
123hi ModeMsg cterm=NONE ctermfg=brown
124hi Normal ctermfg=252 ctermbg=None
125hi CursorLine ctermfg=NONE ctermbg=NONE cterm=none
126"hi CursorLine cterm=bold,reverse
127"hi CursorLineNr cterm=reverse
128hi CursorLineNr ctermfg=0 ctermbg=220 cterm=none
129hi CursorLineNC ctermfg=NONE ctermbg=NONE cterm=none
130
131" Shortcuts key set
132nmap <C-t> :tabnew<cr>
133nmap <C-p> :tabprevious<cr>
134nmap <C-n> :tabnext<cr>
135nmap <C-k> :tabclose<cr>
136nmap <C-Tab> :tabnext<cr>

第三方好用的app

总结

总的来说,mac mini m4和mbp使用起来还是有些不同的,有些东西要比mbp稍微麻烦一丢丢,但是这都是能接受的小问题,毕竟是apple系的东西。小东西的计算性能没得说,扛扛的,这也是我购买的主要原因。好了,今天配置记录先写到这,后续会分享更多关于mac nini m4的相关内容。