MacOS Configuration - MacOS 环境配置(系统设置)

小问题很多,丝毫不逊色 Bug11,特地整篇 blog 记录下

  • 默认输入法 CapsLock 切换卡顿
  • 常用快捷键
  • Clang VSCode 下的 C/C++ 环境配置

默认输入法 CapsLock 切换卡顿

  • Reference: 有关 Macbook“中/英(Caps lock)”键”间歇失灵“的问题

写代码的时候,聊完微信/search 完,快速 CapsLock 切换导致卡顿,有时候还切不过去,这不能忍,一通 search,问题出在默认的键盘设置上

进入设置>键盘>,点文字输入法下面右边的编辑

修改输入设置

把上面这个「使用“中/英”键切换“ABC”输入法」的选项关掉,这个选项是用 CapsLock 切换输入法而非切换中英文输入,简体拼音输入法有自己的中英文输入切换,把这个选项取消掉之后,点 CapsLock 就是切换中英文输入,这时使用 ctrl+space 切换输入法,或 ctrl+option+space 切换最近两个输入法 。

常用快捷键

  • 截图
    • cmd+shift+4 框选截图
    • cmd+shift+5 可以选择窗口截图等功能
  • 文本编辑
    • fn+left Home
    • fn+right End
    • cmd+A 行首
    • cmd+E 行尾 (这俩的行为似乎是不一样的,可能还是 fn 的更好用)
  • 窗口操作
    • cmd+tab 切换打开的程序,按 tab 从左往右依次框选,如果这个程序使用 cmd+h 隐藏,那么这样就能切换,但是如果你通过左上角的 x 或者 -,就需要这时候再按住option,然后一起松开(睿智)。

Clang VSCode 下的 C/C++ 环境配置

WTF,怎么会有这么弱智的问题,默认用 C/C++ 的拓展,程序会在 debug console 输出,但是你不能输入,我吃 🍋

找了老半天也没找到 Graceful 的解决方案,最终找到的是一个凑合解,非常麻烦,你需要写 tasks.jsonlaunch.json,解决方案是用的 externalTerminal,通过外部的终端打开程序,然后 debug 正常在 VSCode 中进行,要不然用 lldb 直接终端搞(不过其实也差不太多)。

那么先给出两个 .json

tasks.json
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
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "build active cpp file",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$gcc"],
"group": "build",
"detail": "compiler: /usr/bin/clang++"
},
{
"type": "cppbuild",
"label": "build active c file",
"command": "/usr/bin/clang",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$gcc"],
"group": "build",
"detail": "compiler: /usr/bin/clang"
},
{
"label": "Open Terminal",
"type": "shell",
"command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
"problemMatcher": []
}
]
}
launch.json
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
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "cpp debug - clang++",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "build active cpp file"
},
{
"name": "c debug - clang",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "build active c file"
}
]
}

然后打开一个 .cpp 页面,debug 选择 cpp debug - clang++ 或者你打开一个 .c 页面 debug 选择 c debug - clang,如果你遇到了终端无法弹出的情况,依次选择 Terminal>Run Task>Open Terminal

然后在弹窗中选择给予权限。