6

MacBook macOS 从小白到入门

 3 years ago
source link: https://wsgzao.github.io/post/macbook/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
MacBook macOS 从小白到入门
y2JB0IAD.png

这里做下 MacBook macOS 从小白到入门的持续更新记录

MacBook macOS 从小白到入门

2020 年 11 月 06 日 - 增加 Lunar/gfxCardStatus/Fliqlo/One Switch
2020 年 08 月 18 日 - 增加 uTools/macOS 小助手 / 腾讯柠檬清理 / 超级右键 iRightMouse/QQ 影音 / Apifox
2020 年 03 月 10 日 - 增加 eZip/PicGo/GifCapture/iShot
2019 年 11 月 21 日 - 增加 macOS 生产力工具链推荐
2019 年 03 月 16 日 - 更新 macOS vim 语法高亮的设置方法
2019 年 02 月 28 日 - 更新 macOS 开启关闭 SIP
2019 年 01 月 24 日 - 增加开启 HiDPI 和解决黑屏问题
2018 年 10 月 19 日 - 更新升级 macOS Mojave 后的各种小问题解决方法
2018 年 07 月 25 日 - 补充细节
2018 年 07 月 05 日 - 初稿

阅读原文 - https://wsgzao.github.io/post/macbook/

扩展阅读

Awesome Mac - http://wangchujiang.com/awesome-mac/index.zh.html
BestApp - https://github.com/hzlzh/Best-App
开发效率提升:Mac 生产力工具链推荐


MacBook Pro Essentials

苹果官方编写的 macOS 使用手册,首次打开 Books 时就会出现,非常推荐大家阅读

MacBook Pro Essentials

macOS 使用手册

System Preferences

在任何的操作系统中,首先你需要做一件事就是更新系统,点击窗口左上角的  > 关于本机 > 软件更新 。此外,如果这是一部新的电脑,你还需要到系统设置进行一些适当调整。如何调整,取决于个人喜好。

系统设置 > 触控板

光标与点击

  • 轻拍来点按

置于屏幕上的位置:左边
设置 Dock 图标更小(大小随个人喜好)

  • 自动显示和隐藏 Dock

Finder

Finder > 显示

  • 显示标签页栏
  • 显示路径栏
  • 显示状态栏
  • 自定工具栏 > 去除所有按钮,仅剩搜索栏

Finder > 偏好设置

  • 开启新 Finder 窗口时打开:HOME「用户名」目录
  • 添加 HOME「用户名」目录 和 创建代码文件目录
  • 将 共享的(shared) 和 标记(tags) 目录去掉
  • 去掉蓝牙等无需经常使用的图标
  • 将电池显示设置为百分比

Spotlight

  • 去掉字体和书签与历史记录等不需要的内容
  • 设置合适的快捷键

互联网帐户

  • 添加 iCloud 用户,同步日历,联系人和 Find my mac 等等

English

Trackpad

  • Tap to click

Accessibility -> Mouse & Trackpad -> Trackpad Options

  • Enable dragging | three finger drag

Language & Region

  • Time format | 24-Hour Time
  • click add button | Chinese, Simplified

Language & Region -> Keyboard Preferences -> Shortcuts -> Input Sources

  • Select the previous input source

Display -> Arrangement

  • Drag the graphics and just make what you want
  • if the display rotates 90 degrees then change Rotation to 90° or 270° and click confirm button to save

Extensions -> Touch Bar

  • Customise

Sound -> Output

  • Show volume in menu bar

Mac 键盘快捷键

20191122174620.png
Symbol Key ⌘ Command Key ⌃ Control Key ⌥ Option Key ⇧ Shift Key

我自己常用的快捷键

快捷键 描述 Command(⌘)-C 复制 Command(⌘)-V 粘贴 Command(⌘)-Z 撤销 Command(⌘)-Option-V 剪切粘贴 Command(⌘)-A 全选 Command(⌘)-F 查找 Command(⌘)-S 保存 Command(⌘)-W 关闭当前窗口 Command(⌘)- 空格键 聚焦 Command(⌘)- 方向左键 后退 Command(⌘)- 方向右键 前进 Control-A 移至行或段落的开头 Control-E 移至行或段落的末尾 Control - 空格键 切换输入法(需要手动设置) Control-Command-Q 系统自带锁屏快捷键 Option-Command-C 复制文件路径,当然也可以直接拖拽到命令行

https://support.apple.com/zh-cn/HT201236

Mac Soft

Homebrew - Mac 下必备的包管理工具
https://brew.sh/

Alfred - Mac 下被无数人安利的效率工具,虽然我觉得 Spotlight 暂时够用了
https://www.alfredapp.com/

uTools - 国人开发基于插件式的轻量级工具集软件
https://u.tools/

macOS 小助手(mac 常用命令集合)
https://macwk.com/soft/macos-assistant-macwk

腾讯柠檬清理 - 腾讯官方出品的 macOS 清理工具,代替旧版 Mac 管家
https://lemon.qq.com/

Mounty for NTFS - 免费的 NTFS 支持软件
http://enjoygineering.com/mounty/
Seagate

Sougou Input - 陪伴大家多年的搜狗输入法
https://pinyin.sogou.com/mac/

Visual Studio Code - 代替 JetBrains 重型武器
https://code.visualstudio.com/

Youdao Dict - 网易开发的老牌翻译工具
http://cidian.youdao.com/index-mac.html

Adobe Reader - Adobe 官方免费的 PDF 阅读工具
https://get.adobe.com/reader/

Clearview - 支持 PDF, EPUB, CHM, MOBI 的免费阅读器
https://itunes.apple.com/app/clearview/id557090104?mt=12&ls=1

Evernote - 轻量级的在线笔记类应用内
https://evernote.com/

Dropbox - 最佳的实时同步工具之一
https://www.dropbox.com/

eZip - 国人编写的转为 macOS 而设计的压缩软件,代替 Keka
https://ezip.awehunt.com/

Mac 迅雷 - 支持协议多广告也多,FOLX、Free Download Manager、qBittorrent 都可以作为备选方案
http://mac.xunlei.com/

百度网盘 - 国内的网盘共享基本只剩下百度一家独大了,有时候迅雷离线无法下载可以尝试
https://pan.baidu.com/

IINA - 国人编写的开源视频播放器,备选重新复活的射手影音
https://iina.io/

QQ 影音 - 腾讯内部公认的 5 星产品复活,此前停更的射手影音也复活了,虽然我认为已经有 IINA 这样更好的开源播放器
https://player.qq.com/

PicGo - 国人开发的开源图片上传工具,我 Blog 中使用的图片就是基于 GitHub 的图床
https://github.com/Molunerfinn/PicGo

GifCapture - 开源的 GIF 录制工具
https://github.com/onmyway133/GifCapture

iShot - 或许是最好的截图软件,超越了 Snipaste 和 Xnip
https://apps.apple.com/cn/app/ishot-%E6%88%AA%E5%9B%BE-%E9%95%BF%E6%88%AA%E5%9B%BE-%E6%A0%87%E6%B3%A8%E5%B7%A5%E5%85%B7/id1485844094?mt=12

超级右键 iRightMouse - 通过增加右键功能极大地方便 UI 界面下的各种操作
https://apps.apple.com/cn/app/irightmouse-%E8%B6%85%E7%BA%A7%E5%8F%B3%E9%94%AE/id1497428978?mt=12

FileZilla - 免费开源的 FTP/SFTP 应用
https://filezilla-project.org/download.php?type=client

Clipy - 记录多条粘贴板小工具
https://github.com/Clipy/Clipy

rectangle - 代替 Spectacle 快速调整程序窗口位置的效率工具
https://github.com/rxhanson/Rectangle

Lunar - 智能调节外接显示器亮度
https://lunar.fyi/

gfxCardStatus - 用于调整集成显卡和独立显卡,省电减少发热
https://gfx.io/

Fliqlo - 极简的时钟屏保
https://fliqlo.com/

Sourcetree - 图形化 Git 管理工具
https://www.sourcetreeapp.com/

Microsoft Remote Desktop - Mac 下的微软 RDP 远程桌面登录工具
https://itunes.apple.com/us/app/microsoft-remote-desktop-10/id1295203466?mt=12

PostMan - 免费强大的 HTTP 调试工具
https://www.getpostman.com/

Apifox = Postman + Swagger + Mock 可能是比 Postman 更好用的接口管理平台
https://www.apifox.cn/

网易 MuMu - Android 模拟器
https://mumu.163.com/

VirtualBox - 免费的虚拟机工具,付费类的产品包括 VMware Fusion 和 Parallels
http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

VMware OS Optimization Tool - VMware 开发的 Windows 虚拟机优化工具
https://labs.vmware.com/flings/vmware-os-optimization-tool

Docker Desktop - 如果说之前人人都要懂一点 VM 虚拟机,那么现在就是人人都应该了解一点 Docker 容器
https://www.docker.com/products/docker-desktop

One Switch - 非常强大的一键切换工具,之前很多人推荐用于 1 秒连接蓝牙耳机,相信大家已经比较熟悉了
https://fireball.studio/oneswitch/

Homebrew

https://docs.brew.sh/Installation

1
2
3
4
5
6
7
8
9
10
11
12
13
# install xcode command line tools
xcode-select --install

# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# install packages
brew tap dteoh/sqa
brew install zsh
brew install wget
brew install git
# default install is python3 now, if you need python2 just run `brew install python2`
brew install python

iTerm2 + zsh + Oh My Zsh

iTerm2
https://www.iterm2.com/

Oh My Zsh
http://ohmyz.sh/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# install latest zsh zsh-syntax-highlighting
brew install zsh zsh-syntax-highlighting zsh-autosuggestions

# 修改默认 shell,在 /etc/shells 文件中加入如下一行
vi /etc/shells

/usr/local/bin/zsh
# 然后运行命令切换 shell
chsh -s /usr/local/bin/zsh

# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# 修改主题为 agnoster,增加一行 zsh-syntax-highlighting
vi ~/.zshrc

ZSH_THEME="agnoster"

plugins=(
git
autojump
)

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh

# 解决 Too many files open error
ulimit -n 10000
ulimit -u 2048
# 禁用 brew install 前自动检查更新
export HOMEBREW_NO_AUTO_UPDATE=true

# 可选增加 visual studio code 命令行 code 支持 zsh(新版本 vscode 已经自带支持)
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}

# 刷新环境变量
source ~/.zshrc

# 安装 powerline 字体
git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh

配置 iTerm2 主题,主题可以从 iterm2colorschemes 下载

https://iterm2colorschemes.com/

  1. Download iTerm2 color you like
  2. Open iTerm2 that we already downloaded at the first section
  3. Go to iTerm2 > Preferences > Profiles > Colors Tab
  4. Click Color Presets at the bottom right
  5. Click Import
  6. Select the *.itermcolors file
  7. Select the * from Load Presets

在 Keys -> Hotkey 中设置 command + i 快速显示和隐藏 iTerm
在 Profiles -> Default -> Colors -> Load Presets 导入主题,作为默认颜色,我的主题是 3024 Night
在 Profiles -> Text -> Change Font 调整字体 / 大小 / 颜色等,我的字体是 18pt Ubuntu Mono derivative Powerline

如果 VScode 打开终端 iterm2 乱码可以打开设置搜索 font 修改为以下参数即可解决
Editor: Font Family
Meslo LG M for Powerline,Menlo, Monaco, ‘Courier New’, monospace

macOS 使用笔记:终端配置 - http://lizhiqiang.me/mac_terminal/
打造 Mac 下高颜值好用的终端环境 - https://blog.biezhi.me/2018/11/build-a-beautiful-mac-terminal-environment.html

macOS vim 语法高亮的设置方法

打开 terminal 复制 /usr/share/vim/vimrc 到家目录下并重命名为 “.vimrc”, 然后编辑该文件,增加以下几行:

VimConfig - https://vimconfig.com/
My .vimrc - https://chrisyeh96.github.io/2017/12/18/vimrc.html

1
2
3
4
5
6
7
cp /usr/share/vim/vimrc ~/.vimrc
set ai "auto indenting
set ruler" show the cursor position
set hlsearch "highlight the last searched term
set history=1000" keep 1000 lines of history
syntax on "syntax highlighting
filetype plugin on" use the file type plugins

Others

iTerm2 常见问题

  1. iTerm2 默认使用 dash 改用 zsh 解决方法:chsh -s /bin/zsh
  2. iTerm2 zsh 切换回原来的 dash:chsh -s /bin/bash
  3. 卸载 oh my zsh,在命令行输入:uninstall_oh_my_zsh
  4. 路径前缀的 XX@XX 太长,缩短问题:

编辑 ~/.oh-my-zsh/themes/agnoster.zsh-theme 主体文件,将里面的 build_prompt 下的 prompt_context 字段在前面加 # 注释掉即可

Macbook Pro 16 寸唤醒颜色失真问题

https://discussionschinese.apple.com/thread/250939091

  1. 官网购买的 16 寸开启原彩显示,自动亮度,夜览,屏幕保护程序后,笔记本睡眠唤醒屏幕颜色完全失真。
  2. 将官网的退回后,第三方店铺购买故障依旧。

这篇文章中提到的问题我个人认为是软件和硬度温度升高综合引起的,我也确实遇到了,不能算是硬件故障选择去苹果店维修或者更换也无法彻底解决
我自己的做法是选择调整 Displays 设置,如果想复现问题关闭再打开 True Tone 就可以看到效果,应该还是软件问题

  • 关闭 Automatically adjust brightness
  • 打开 True Tone

升级 macOS Mojave 新版卡顿黑屏和字体发虚解决方案

输入文字卡顿

如果你的 Mac 已经更新至 macOS Mojave,在输入文字时经常卡顿,频繁出现小风车,那很有可能是搜狗输入法造成的,只需将它升级至最新的 4.8.0 版本,即可完美解决。

升级 macOS Mojave 新系统后,苹果默认关闭了子像素抗锯齿,导致字体变细锯齿增多。
解决字体渲染过细,打开终端,输入:

defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO

重启应用比如 VS Code 后即可看到效果

开启 HiDPI

如果外接显示器字体模糊,可以使用 Scale Resolutions
Display Override PropertyList File Parser and Generator with HiDPI support

https://comsysto.github.io/Display-Override-PropertyList-File-Parser-and-Generator-with-HiDPI-Support-For-Scaled-Resolutions/

Enable HiDPI on OS X - https://github.com/syscl/Enable-HiDPI-OSX

解决唤醒时黑屏只看见鼠标的问题

先关机,然后开机快速同时点击 Command + S 按键进入 single-user 单用户模式

1
2
3
4
5
/sbin/fsck -fy
/sbin/mount -uw /
rm -f /Library/Preferences/com.apple.loginwindow.plist
rm -f /var/db/.AppleUpgrade
reboot

解决 Command+Q 经常误按

Slow Quit Apps

A macOS app that adds a global delay of 1 second to the Cmd-Q shortcut. In other words, you have to hold down Cmd-Q for 1 second before an application will quit.

When the delay is active, an overlay is drawn at the center of the screen.

https://github.com/dteoh/SlowQuitApps

brew cask install slowquitapps

运行程序按照提示授权后重启应用并设置开机自启动即可享受 1s 延迟关闭提醒,如果觉得时间不够长可以自己设定

提示应用程序被破坏无法打开

SOLVED: “Application” is damaged and can’t be opened in macOS Sierra

sudo spctl --master-disable

输入密码重新打开 System Preferences > Security & Privacy > General 即可看到之前隐藏的“Anywhere”
https://www.santoshsrinivas.com/disable-gatekeeper-in-macos-sierra/

macOS High Seirra 提示 “已损坏,打不开,您应该将它移至垃圾篓”

这是因为在系统偏好设置的 “安全性与隐私” 里面的 “允许从以下位置下载的应用” 没有选中“任何来源”,解决方法如下:

  1. 打开终端,然后输入以下命令:sudo spctl –master-disable
  2. 然后回车,输入系统密码并回车(这里输入密码不会显示,输完密码直接回车即可),如果没有提示即操作成功。
  3. 打开系统偏好设置的 “安全性与隐私”,查看“允许从以下位置下载的应用” 是否选中的是“任何来源”,如果选中说明操作成功。这时再打开软件安装就没有已损坏的提示的了。

macOS 开启关闭 SIP

S1. 查看 SIP 状态
在终端中输入 csrutil status,就可以看到是 enabled 还是 disabled。

S2. 关闭 SIP

  1. 重启 MAC,按住 cmd+R 直到屏幕上出现苹果的标志和进度条,进入 Recovery 模式;
  2. 在屏幕最上方的工具栏找到实用工具(左数第 3 个),打开终端,输入:csrutil disable;
  3. 关掉终端,重启 mac;
  4. 重启以后可以在终端中查看状态确认。

S3. 开启 SIP
与关闭的步骤类似,只是在 S2 中输入 csrutil enable 即可。

更改 Apple ID 国家或地区

区域在国内即使身在国外也看不到你需要的很多东东,建议修改

https://support.apple.com/zh-cn/ht201389

USB Type-C 耳机

  1. 插入耳机至任意 USB Type-C 接口
  2. System Preferences -> Sound -> Output -> 选择识别到的耳机设备即可

Macbook 外置键盘如何更改设置

option 改成 command(win 版键盘下的四个方块图标按键)
command 改成 option

https://jingyan.baidu.com/article/363872ec2185346e4aa16f61.html

配置从命令提示行启动 vscode

安装 Visual Studio Code,打开命令面板(按 F1 或 command + shift + p)输入 Shell 命令找到 Shell 命令: 在 PATH 中安装 “code” 命令。命令执行完成之后,重启终端工具使新的 $PATH 可用。现在,您可以简单地在终端中任意文件夹下输入‘code .’来编辑该文件夹下的文件了。

Git Ignore

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 创建一个新文件 ~/.gitignore ,并将以下内容添加进去,这样全部 git 仓库将会忽略以下内容所提及的文件。

# Folder view configuration files
.DS_Store
Desktop.ini

# Thumbnail cache files
._*
Thumbs.db

# Files that might appear on external disks
.Spotlight-V100
.Trashes

# Compiled Python files
*.pyc

# Compiled C++ files
*.out

# Application specific files
venv
node_modules
.sass-cache

# Temp File
*.swp
*.swa
*.swo

# github merge file
*.orig

#vscode
.vscode

禁止. DS_store 生成

1
2
3
4
5
6
# 禁止 .DS_store 生成,打开“终端”,复制黏贴下面的命令,回车执行,重启 Mac 即可生效。
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
# 恢复 .DS_store 生成
defaults delete com.apple.desktopservices DSDontWriteNetworkStores
# 刪除已存在的. DS_Store
sudo find . -name ".DS_Store" -depth -exec rm {} \;

ssh 相关

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
# 禁止 OpenSSH 客户端从 OS X/Linux/Unix 桌面发送 LC_* 变量
vi /etc/ssh/ssh_config
#SendEnv LANG LC_*

# port forwarding
ssh -p 22202 [email protected]
ssh -p 22202 [email protected] -X
scp -P 22202 -r sysctl.sh sysctl.d/ [email protected]:/tmp

# ssh tunnel for one-time
ssh -t -A [email protected] ssh [email protected]

# config ssh tunnel to make easy connect everyday
vim ~/.ssh/config

StrictHostKeyChecking no
CheckHostIP no

Host 10.71.12.*
HostName %h
ProxyCommand ssh bastion_GOP_SG_NC_MAIN -W %h:%p

Host 10.71.13.*
HostName %h
ProxyCommand ssh bastion_GOP_SG_NC_MAIN -W %h:%p

Host 10.71.14.*
HostName %h
ProxyCommand ssh bastion_GOP_SG_NC_MAIN -W %h:%p

Host 10.71.15.*
HostName %h
ProxyCommand ssh bastion_GOP_SG_NC_MAIN -W %h:%p

Host bastion_GOP_SG_NC_MAIN
HostName 8.8.8.8
port 22
User wangao

题图 - 苹果 2015 新春广告《老唱片》


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK