w h y y o u a r e h e r e ?

程序员使用Mac笔记

写笔记,可以增加生命的厚度。

如果能过目不忘且可温故知新,那就可以不记笔记了,否则就是轻视世界加轻视自己的一条咸鱼 —— 相信我,你会丢掉好多时光。

Mac 系统设置

Spotlight - 搜索文件内容设置

  1. 点按 “System Preferences” ➡️ “Spotlight” 的 “Search results” 和 “Privacy” 选项。前者可配置要搜索的文件类型。

  2. 当搜索结果无法搜到想要的结果时,可能 需要重新建立索引(系统升级会导致此问题),步骤如下:

    1
    2
    3
    4
    5
    点按 “System Preferences” ➡️ “Spotlight”。
    点按 “Privacy” 选项。
    将您想要再次为其创建索引的目录(文件夹或磁盘)拖至 Spotlight 无法搜索的位置列表中。或点按 “Add(+)” 按钮,并选择要添加的目录。(要将某个项目添加到 “Privacy” 标签中,您须拥有该项目的所有权。要了解有关权限信息,请从 “Finder” 菜单栏中选取 “Help”,然后搜索 “权限”(如果你是中文系统))
    从相同的位置列表中,选择您刚添加的目录。然后点按 “(-)” 按钮,将其从列表中移除。
    退出 “System Preferences”。Spotlight 将重新为刚才目录中的内容创建索引。

Finder - 文件管理器搜不到的文件设置

“user”(你的名字)下其实有个看不见的 “Library” 文件夹,系统默认不可见。

方法1:(推荐)

1
打开 Finder,按 shift+command+.,这样隐藏的文件就回出现。

方法2:

1
打开 Finder,按 shift+command+g,输入“~/Library”,回车,进入 “Library” 下。

这样就可以找一些难找的文件(比如优酷下载的视频文件,在 “/Library/Containers/com.youku.mac/Data” 下)。

设定可以在指定文件夹内打开 iTerm 命令行

方法1:(推荐)

1
2
3
4
点按 “system preferences” ➡️ “Keyboard” ➡️ “Shortcuts”。
左侧栏点按 “Services”,右侧点按 “Files and Folders” 下的 “New Terminal at Folder”。
按键盘对应的组合键值进行设定。
验证:Finder 中选定一个文件夹,按刚才的组合快捷键。

方法2:

1
2
3
4
5
打开 “Automator” ➡️ 选 “Services” ➡️ “Choose”。
选定 “folders” ,in “Finder.app”。
左侧搜索找到 “Open Finder Iterms” ,拖拽到右侧。
CMD+S 存储为 “...”(你想叫的功能名字)。
验证:Finder 中选定一个文件夹,右键 ➡️ “Services” ➡️ 找到你第4步命名的功能。

比如把这个功能叫做 open-iterm-in-folder


开机启动项

方法1:(推荐)

1
“system preferences” ➡️ “Users & Groups” ➡️ “Login Items”,添加或删除想操作的应用。

方法2:
Macintosh HD 磁盘下文件操作:

1
2
“Library” 下 “Launch...” 内的 .plist 文件。
“System/Library” 下 “Launch...” 内的 .plist文件。

它们属于系统文件,可以做如下处理:

  1. 删除 .plist文件(不建议,万一以后要用呢)。
  2. 执行以下命令:
    1
    launchctl unload -w /Library/Launch.../... .plist

命令参考链接

Mac 优秀软件

mpv 播放器使用指南

播放速度

1
2
3
4
5
6
7
8
9
10
11
12
13
14
space - 暂停/播放

快:
⬆️ - 快进60s
➡️ - 快进5s
] - 1.1倍快速播放
} - 2倍快速播放

慢:
⬇️ - 快退60s
⬅️ - 快退5s
[ - 0.9倍慢速播放
{ - 0.5倍慢速播放
Backspace - 重置为正常播放速度

字幕 音轨

1
2
3
4
j(J) - 循环(反向)选择字幕文件
# - 循环切换音轨
9 - 音量减 2
0 - 音量加 2

屏幕相关

1
2
3
4
5
6
7
f - 切换全屏
shift+t - 切换视频窗口在最前
s(S) - 视频截图,包含(不包含)字幕
Alt+s - 自动逐帧视频截图,再按一次停止截图
. - 进到下一帧
, - 退到前一帧
shift+Q - 关闭软件

高级配置(这里才是玩Mac的程序员的G点)

/Users/yourname/.config/mpv 下(~/.config/mpv)新建如下文件实现不同配置。

一般配置:mpv.conf
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
no-osd-bar # 去掉白色进度条
save-position-on-quit # 关闭时记住文件播放位置
no-border # 去掉边框

# 解码-字幕
vo=opengl:gamma-auto:icc-profile-auto
hwdec=auto
autofit-larger=92%
playcache=8192
lang=zh,chi
video-sync=display-resample

sub-codepage=enca:zh:utf8
sub-auto=fuzzy
sub-text-font-size=40
sub-text-shadow-offset=0
sub-text-color="#ffffffff"
sub-text-font="STZhongsong"
sub-codepage=utf8:gb18030

screenshot-template=mpv-screenshot-%f-%p
screenshot-format=png

osd-font="STZhongsong"
osd-font-size=36

--script=/Users/yourname/.config/mpv/autoload.lua

上面最后一行代码加载lua脚本用来配置播放列表。这样本文件夹下视频文件可自动连续播放, < 和 > 实现上一曲下一曲切换。新建 autoload.lua:

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
-- This script automatically loads playlist entries before and after the
-- the currently played file. It does so by scanning the directory a file is
-- located in when starting playback. It sorts the directory entries
-- alphabetically, and adds entries before and after the current file to
-- the internal playlist. (It stops if the it would add an already existing
-- playlist entry at the same position - this makes it "stable".)
-- Add at most 5000 * 2 files when starting a file (before + after).
MAXENTRIES = 5000

function Set (t)
local set = {}
for _, v in pairs(t) do set[v] = true end
return set
end

EXTENSIONS = Set {
'mkv', 'avi', 'mp4', 'ogv', 'webm', 'rmvb', 'flv', 'wmv', 'mpeg', 'mpg', 'm4v', '3gp',
'mp3', 'wav', 'ogv', 'flac', 'm4a', 'wma',
}

mputils = require 'mp.utils'

function add_files_at(index, files)
index = index - 1
local oldcount = mp.get_property_number("playlist-count", 1)
for i = 1, #files do
mp.commandv("loadfile", files[i], "append")
mp.commandv("playlist-move", oldcount + i - 1, index + i - 1)
end
end

function get_extension(path)
match = string.match(path, "%.([^%.]+)$" )
if match == nil then
return "nomatch"
else
return match
end
end

table.filter = function(t, iter)
for i = #t, 1, -1 do
if not iter(t[i]) then
table.remove(t, i)
end
end
end

function find_and_add_entries()
local path = mp.get_property("path", "")
local dir, filename = mputils.split_path(path)
if #dir == 0 then
return
end
local pl_count = mp.get_property_number("playlist-count", 1)
if (pl_count > 1 and autoload == nil) or
(pl_count == 1 and EXTENSIONS[string.lower(get_extension(filename))] == nil) then
return
else
autoload = true
end

local files = mputils.readdir(dir, "files")
if files == nil then
return
end
table.filter(files, function (v, k)
local ext = get_extension(v)
if ext == nil then
return false
end
return EXTENSIONS[string.lower(ext)]
end)
table.sort(files, function (a, b)
local len = string.len(a) - string.len(b)
if len ~= 0 then -- case for ordering filename ending with such as X.Y.Z
local ext = string.len(get_extension(a)) + 1
return string.sub(a, 1, -ext) < string.sub(b, 1, -ext)
end
return string.lower(a) < string.lower(b)
end)

if dir == "." then
dir = ""
end

local pl = mp.get_property_native("playlist", {})
local pl_current = mp.get_property_number("playlist-pos", 0) + 1
-- Find the current pl entry (dir+"/"+filename) in the sorted dir list
local current
for i = 1, #files do
if files[i] == filename then
current = i
break
end
end
if current == nil then
return
end

local append = {[-1] = {}, [1] = {}}
for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1
for i = 1, MAXENTRIES do
local file = files[current + i * direction]
local pl_e = pl[pl_current + i * direction]
if file == nil or file[1] == "." then
break
end

local filepath = dir .. file
if pl_e then
-- If there's a playlist entry, and it's the same file, stop.
if pl_e.filename == filepath then
break
end
end

if direction == -1 then
if pl_current == 1 then -- never add additional entries in the middle
mp.msg.info("Prepending " .. file)
table.insert(append[-1], 1, filepath)
end
else
mp.msg.info("Adding " .. file)
table.insert(append[1], filepath)
end
end
end

add_files_at(pl_current + 1, append[1])
add_files_at(pl_current, append[-1])
end

mp.register_event("start-file", find_and_add_entries)
快捷键配置:input.conf
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# mpv keybindings
# Location of user-defined bindings: ~/.config/mpv/input.conf
# Lines starting with # are comments. Use SHARP to assign the # key.
# Copy this file and uncomment and edit the bindings you want to change.
# List of commands and further details: DOCS/man/input.rst
# List of special keys: --input-keylist
# Keybindings testing mode: mpv --input-test --force-window --idle
# Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore').
# Strings need to be quoted and escaped:
# KEY show-text "This is a single backslash: \\ and a quote: \" !"
# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with
# the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal).
# The default keybindings are hardcoded into the mpv binary.
# You can disable them completely with: --no-input-default-bindings
# Developer note:
# On compilation, this file is baked into the mpv binary, and all lines are
# uncommented (unless '#' is followed by a space) - thus this file defines the
# default key bindings.
# If this is enabled, treat all the following bindings as default.
#------------------------------------------------------------------------------------------------
#default-bindings start
#------------------------------------------------------------------------------------------------
#MOUSE_BTN0 ignore # don't do anything
#MOUSE_BTN0_DBL cycle fullscreen # toggle fullscreen on/off
#MOUSE_BTN2 cycle pause # toggle pause on/off
#MOUSE_BTN3 seek 10
#MOUSE_BTN4 seek -10
#MOUSE_BTN5 add volume -2
#MOUSE_BTN6 add volume 2

MOUSE_BTN0 show-progress
MOUSE_BTN1 cycle fullscreen
MOUSE_BTN3 add volume 5
MOUSE_BTN4 add volume -5

#------------------------------------------------------------------------------------------------
# Mouse wheels, touchpad or other input devices that have axes
# if the input devices supports precise scrolling it will also scale the
# numeric value accordingly
#------------------------------------------------------------------------------------------------
#AXIS_UP seek 10
#AXIS_DOWN seek -10
#AXIS_LEFT seek 5
#AXIS_RIGHT seek -5
#------------------------------------------------------------------------------------------------
# Seek units are in seconds, but note that these are limited by keyframes
#------------------------------------------------------------------------------------------------
#RIGHT seek 5
#LEFT seek -5
#UP seek 60
#DOWN seek -60

RIGHT seek 5
LEFT seek -5
UP add volume 5
DOWN add volume -5

#------------------------------------------------------------------------------------------------
# Do smaller, always exact (non-keyframe-limited), seeks with shift.
# Don't show them on the OSD (no-osd).
#------------------------------------------------------------------------------------------------
#Shift+RIGHT no-osd seek 1 exact
#Shift+LEFT no-osd seek -1 exact
#Shift+UP no-osd seek 5 exact
#Shift+DOWN no-osd seek -5 exact
#------------------------------------------------------------------------------------------------
# Skip to previous/next subtitle (subject to some restrictions; see manpage)
#------------------------------------------------------------------------------------------------
#Ctrl+LEFT no-osd sub-seek -1
#Ctrl+RIGHT no-osd sub-seek 1
#PGUP add chapter 1 # skip to next chapter
#PGDWN add chapter -1 # skip to previous chapter
#Shift+PGUP seek 600
#Shift+PGDWN seek -600
#[ multiply speed 0.9091 # scale playback speed
#] multiply speed 1.1
#{ multiply speed 0.5
#} multiply speed 2.0
#BS set speed 1.0 # reset speed to normal,BS=BackSpace
#q quit
#Q quit-watch-later
#q {encode} quit 4
#ESC set fullscreen no
#ESC {encode} quit 4
#p cycle pause # toggle pause/playback mode
#. frame-step # advance one frame and pause
#, frame-back-step # go back by one frame and pause
#SPACE cycle pause
#> playlist-next # skip to next file
#ENTER playlist-next # skip to next file
#< playlist-prev # skip to previous file
#O no-osd cycle-values osd-level 3 1 # cycle through OSD mode
#o show-progress
#P show-progress
#I show-text "${filename}" # display filename in osd
#z add sub-delay -0.1 # subtract 100 ms delay from subs
#x add sub-delay +0.1 # add
#ctrl++ add audio-delay 0.100 # this changes audio/video sync
#ctrl+- add audio-delay -0.100
#9 add volume -2
#/ add volume -2
#0 add volume 2
#* add volume 2
#m cycle mute
#1 add contrast -1
#2 add contrast 1
#3 add brightness -1
#4 add brightness 1
#5 add gamma -1
#6 add gamma 1
#7 add saturation -1
#8 add saturation 1
#Alt+0 set window-scale 0.5
#Alt+1 set window-scale 1.0
#Alt+2 set window-scale 2.0
#------------------------------------------------------------------------------------------------
# toggle deinterlacer (automatically inserts or removes required filter)
#------------------------------------------------------------------------------------------------
#d cycle deinterlace
#r add sub-pos -1 # move subtitles up
#t add sub-pos +1 # down
#v cycle sub-visibility
#------------------------------------------------------------------------------------------------
# stretch SSA/ASS subtitles with anamorphic videos to match historical
#V cycle sub-ass-vsfilter-aspect-compat
#------------------------------------------------------------------------------------------------
# switch between applying no style overrides to SSA/ASS subtitles, and
# overriding them almost completely with the normal subtitle style
#------------------------------------------------------------------------------------------------
#u cycle-values sub-ass-style-override "force" "no"
#j cycle sub # cycle through subtitles
#J cycle sub down # ...backwards
#SHARP cycle audio # switch audio streams
#_ cycle video
#T cycle ontop # toggle video window ontop of other windows
#f cycle fullscreen # toggle fullscreen
ENTER cycle fullscreen
#s screenshot # take a screenshot
#S screenshot video # ...without subtitles
#Ctrl+s screenshot window # ...with subtitles and OSD, and scaled
#Alt+s screenshot each-frame # automatically screenshot every frame
#w add panscan -0.1 # zoom out with -panscan 0 -fs
#e add panscan +0.1 # in
#------------------------------------------------------------------------------------------------
# cycle video aspect ratios; "-1" is the container aspect
#------------------------------------------------------------------------------------------------
#A cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"
#POWER quit
#PLAY cycle pause
#PAUSE cycle pause
#PLAYPAUSE cycle pause
#STOP quit
#FORWARD seek 60
#REWIND seek -60
#NEXT playlist-next
#PREV playlist-prev
#VOLUME_UP add volume 2
#VOLUME_DOWN add volume -2
#MUTE cycle mute
#CLOSE_WIN quit
#CLOSE_WIN {encode} quit 4
#E cycle edition # next edition
#l ab-loop # Set/clear A-B loop points
#L cycle-values loop "inf" "no" # toggle infinite looping
#ctrl+c quit 4
#------------------------------------------------------------------------------------------------
# Apple Remote section
#------------------------------------------------------------------------------------------------
#AR_PLAY cycle pause
#AR_PLAY_HOLD quit
#AR_CENTER cycle pause
#AR_CENTER_HOLD quit
#AR_NEXT seek 10
#AR_NEXT_HOLD seek 120
#AR_PREV seek -10
#AR_PREV_HOLD seek -120
#AR_MENU show-progress
#AR_MENU_HOLD cycle mute
#AR_VUP add volume 2
#AR_VUP_HOLD add chapter 1
#AR_VDOWN add volume -2
#AR_VDOWN_HOLD add chapter -1
#------------------------------------------------------------------------------------------------
# For tv://
#------------------------------------------------------------------------------------------------
#h cycle tv-channel -1 # previous channel
#k cycle tv-channel +1 # next channel
#------------------------------------------------------------------------------------------------
# For dvb://
#------------------------------------------------------------------------------------------------
#H cycle dvb-channel-name -1 # previous channel
#K cycle dvb-channel-name +1 # next channel
#------------------------------------------------------------------------------------------------
# Legacy bindings (may or may not be removed in the future)
#------------------------------------------------------------------------------------------------
#! add chapter -1 # skip to previous chapter
#@ add chapter 1 # next
#------------------------------------------------------------------------------------------------
# Not assigned by default
# (not an exhaustive list of unbound commands)
#------------------------------------------------------------------------------------------------
# ? add sub-scale +0.1 # increase subtitle font size
# ? add sub-scale -0.1 # decrease subtitle font size

Alt+= add sub-scale 0.1
Alt+- add sub-scale -0.1

# ? sub-step -1 # immediately display next subtitle
# ? sub-step +1 # previous
# ? cycle angle # switch DVD/Bluray angle
# ? add balance -0.1 # adjust audio balance in favor of left
# ? add balance 0.1 # right
# ? cycle sub-forced-only # toggle DVD forced subs
# ? cycle program # cycle transport stream programs
# ? stop # stop playback (quit or enter idle mode)

拓展链接

Mac 输入法

< - 完 - >
- 坚持分享 鼓励创作 -