0%

Macos 炫炮配制,一個鍵盤打天下

程序員就是一種會花兩天的時間去研究怎麼直接把水自動的從十米遠的廚房送到自己嘴裡的 人。

看完這篇,你會學到

怎麼在幾乎不用滑鼠的情況下快速在各種視窗移動

技能點++

  1. tilling window manager
    • aerospace
  2. home row mode(這個老酷了)
  3. 如何精準的消秏自己的肝
  4. spacemacs
    • 很想傳教(誤

起因

就跟女生會有生理期一樣,我每個月也會有幾天特別的不舒服,手會特別的癢,會一直找有什 麼酷酷的軟體可以讓我花大把大把的時間配制去節省小小的時間。這篇文章就是紀錄一下我目 前的配置(需要花大把大把時間的才放xd 像Arc的就自己隨便裝裝就好xd)。還有解決一下我 遇到的衝突跟我是怎麼曲線救國救回來的。


aerospace

什麼是Tiling manager

簡單來說,通常預設的都是Window Manager,所有的視窗都是可以自由拖動的,自由度非常 高,也代表熵增特別快,<Ctrl>+<Tab>很容易按到冒煙。

  • 優點:自由度高
  • 缺點:很容易亂,效率低(要用滑鼠)

和他相反的就是Tiling Manger,就是把你的window限定成特定的排板。像 vim,tmux的分頁都是這種感覺的。

  • 優點:簡單,易上手(如果有用過vim的話)
  • 缺點:一開始須要時間熟悉一下、然後要找到適合自己的配置需要一點時間

配置

Aerospace的配置蠻簡單的 可以看一下這個影片

下載

1
brew install --cask nikitabobko/tap/aerospace

主要的設定都會放在~/.config/aerospace/aerospace.toml

一點小小的問題

如果你剛好也是一個emacs重度使用患者的話,你也會發現emacs會把Alt+<1~9>的 keybinding 都吃掉qq,這個時候就除了把emacs關掉之外沒有其他辨法可以逃走了

可能也只有我這個小天才會把home row mode, tiling window, emacs一起用

如果你沒有用emacs的話,那一切都很好。但如果你跟我一樣被org mode推坑的話,那 你就會發現你的aerospace會跟emacskeybinding打架。

這個時候你有三種解決方法

  1. 放棄emacs
  2. 放棄aerospace
  3. aerospace的快截鍵然後手抽筋

那當然是選擇三拉(誤

我們先一個一個來,先解決衝突的問題然後再來看怎麼樣可以優化方法。(先讓他能動再說 我的做法是因為我發現我其實不會用到alt+[1-9],所以其實我可以把東東都映射到那上 面。

然後像如果不夠的話再加上cmd

cmd+atl+[6~8] -> vim 內hjkl的移動

詳情請見我的aerospace.toml

aerospace.toml
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
[mode.main.binding]
alt-slash = 'layout tiles horizontal vertical'
alt-comma = 'layout accordion horizontal vertical'

# See: https://nikitabobko.github.io/AeroSpace/commands#focus
# alt-h = 'focus left'
# alt-j = 'focus down'
# alt-k = 'focus up'
# alt-l = 'focus right'
cmd-alt-6 = 'focus left'
cmd-alt-7 = 'focus down'
cmd-alt-8 = 'focus up'
cmd-alt-9 = 'focus right'

# See: https://nikitabobko.github.io/AeroSpace/commands#move
cmd-alt-shift-6 = 'move left'
cmd-alt-shift-7 = 'move down'
cmd-alt-shift-8 = 'move up'
cmd-alt-shift-9 = 'move right'

# See: https://nikitabobko.github.io/AeroSpace/commands#resize
alt-shift-minus = 'resize smart -50'
alt-shift-equal = 'resize smart +50'

# See: https://nikitabobko.github.io/AeroSpace/commands#workspace
alt-1 = 'workspace 1'
alt-2 = 'workspace 2'
alt-3 = 'workspace 3'
alt-4 = 'workspace 4'
alt-5 = 'workspace 5'
alt-6 = 'workspace 6'
alt-7 = 'workspace 7'
alt-8 = 'workspace 8'
alt-9 = 'workspace 9'
# # alt-a = 'workspace A' # In your config, you can drop workspace bindings that you don't need
# alt-c = 'workspace C'

# See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace
alt-shift-1 = 'move-node-to-workspace 1'
alt-shift-2 = 'move-node-to-workspace 2'
alt-shift-3 = 'move-node-to-workspace 3'
alt-shift-4 = 'move-node-to-workspace 4'
alt-shift-5 = 'move-node-to-workspace 5'
alt-shift-6 = 'move-node-to-workspace 6'
alt-shift-7 = 'move-node-to-workspace 7'
alt-shift-8 = 'move-node-to-workspace 8'
alt-shift-9 = 'move-node-to-workspace 9'
# alt-shift-a = 'move-node-to-workspace A'

# See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth
cmd-alt-tab = 'workspace-back-and-forth'
# See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor
cmd-shift-alt-tab = 'move-workspace-to-monitor --wrap-around next'

# See: https://nikitabobko.github.io/AeroSpace/commands#mode
alt-shift-semicolon = 'mode service'

# 'service' binding mode declaration.
# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes
[mode.service.binding]
esc = ['reload-config', 'mode main']
r = ['flatten-workspace-tree', 'mode main'] # reset layout
f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout
backspace = ['close-all-windows-but-current', 'mode main']

# sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2
#s = ['layout sticky tiling', 'mode main']

alt-shift-6 = ['join-with left', 'mode main']
alt-shift-7 = ['join-with down', 'mode main']
alt-shift-8 = ['join-with up', 'mode main']
alt-shift-9 = ['join-with right', 'mode main']

雖然說你可能會想說(這尛,cmd+alt+shift+6這是給人按的嗎?
你就說他會不會動,這不是就動起來了嗎

但,沒事,只要再多繞一個彎,一切就解決了


home row mode(with Kmonad)

什麼是home row mode

第一次查到之前我幾乎沒有聽過這個酷酷的東東。這是一個你可以正常打英文。但當你按住 S+7的時候,他可以變成Alt+7的酷酷東東

簡單來說就是有點像把CTRL, ALT, CMD, SHIFT搬到ASDF,JKL:的感覺,是一個很神奇 的體驗,要自己試過才知道。

我是使用Kmonad來達成的,你可以直接抄我的配置。 我是

Caps \(\to\)Left Control
S \(\to\)Left Option
D \(\to\)Left Cmd
F \(\to\)Left Shift
J \(\to\)Right Shift
K \(\to\)Right Cmd
L \(\to\)Right Option
' \(\to\)Right Control

因為我習慣了Caps \(\to\) Left Control,所以就順變把Right Control也往右移一格 了。

我的配置

如何安裝Kmonad

/Library/LaunchDaemons/local.kmonad.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.kmonad</string>
<key>Program</key>
<string>/Users/guoshengwei/.local/bin/kmonad</string>
<key>ProgramArguments</key>
<array>
<string>/Users/guoshengwei/.local/bin/kmonad</string>
<string>/Users/guoshengwei/.config/config.kbd</string>
</array>
<key>RunAtLoad</key>
<false />
<key>KeepAlive</key>
<true />
<key>StandardOutPath</key>
<string>/tmp/kmonad.stdout</string>
<key>StandardErrorPath</key>
<string>/tmp/kmonad.stderr</string>
</dict>
</plist>
~/.config/.config/config.kbd
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
 (defcfg
input (iokit-name)
output (kext)

;; Comment this if you want unhandled events not to be emitted
fallthrough true

;; Set this to false to disable any command-execution in KMonad
allow-cmd true
)

(defalias
ctrl_a (tap-hold-next-release 200 a lctl)
ctrl_' (tap-hold-next-release 200 ' rctl)
opt_s (tap-hold-next-release 200 s lalt)
opt_l (tap-hold-next-release 200 l ralt)
cmd_d (tap-hold-next-release 200 d lmet)
cmd_k (tap-hold-next-release 200 k rmet)
sft_f (tap-hold-next-release 200 f lsft)
sft_j (tap-hold-next-release 200 j rsft)

anom (layer-add nom)
rnom (layer-rem nom)
cnom (layer-toggle nom)
)

(defsrc
f10 f11 12
tab q w e r t u i o p
caps a s d f g h j k l ; '
lsft z x c v b n m , . /
fn lctl lalt lmet space
)

(deflayer bas
mute vold volu
tab q w e r t u i o p
lctl a @opt_s @cmd_d @sft_f g h @sft_j @cmd_k @opt_l ; @ctrl_'
lsft z x c v b n m , . /
fn @cnom lalt lmet space
)

(defalias
mv1 (around alt 1)
mv2 (around alt 2)
mv3 (around alt 3)
mv4 (around alt 4)
mv5 (around alt 5)
hopt (around lmet (around alt 6))
jopt (around lmet (around alt 7))
kopt (around lmet (around alt 8))
lopt (around lmet (around alt 9))
semi (around alt :)
jsfopt (tap-hold-next-release 200 @jopt rsft)
mvsf4 (tap-hold-next-release 200 @mv4 lsft)
)
(deflayer nom
f10 f11 f12
tab q w e a t u i o p
caps @mv1 @mv2 @mv3 @mvsf4 @mv5 @hopt @jsfopt @kopt @lopt @semi '
lsft z x c v b n m , . /
fn @cnom lalt lmet space
)

問題

注音

aerospace + home row mode 對注音極度不友好

aerospace + home row mode打注音真的是相當坐牢,我打要(u l 4)他會變成(u Alt+4)然後就直接跳頁面了...

解決方法

使用無蝦米之類的東東,會這樣的原因是因為注音會用到[1~9]的位置,所以就不太好。