-
Notifications
You must be signed in to change notification settings - Fork 1
/
.khdrc
192 lines (159 loc) · 8.64 KB
/
.khdrc
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
##############################
##### JackyChiu ######
##### khd Dotfile ######
##############################
# NOTE(koekeishiya): A bind is written in the form:
# <keysym> [!] [<app list>] [->] : <command>
# where
# <keysym> = mode + mod + ... + mod - literal
#
# <keysym> = mode + mod + ... + mod - keycode
# keycode must have 0x prefix
#
# <keysym> = mode + mod + ... + mod - button#
# replace '#' with mouse-button id; id >= 3
#
# modifier only binding
# <keysym> = mode + mod + ... + mod
#
# literal only binding
# <keysym> = - literal
#
# keycode only binding
# <keysym> = - keycode
#
# [<app,
# app, = optional list '[app1, ..., appN]' of applications
# app>] that this bind will be activated for. if the
# focused application is not contained in this list,
# the associated command will not be triggered, and
# the keypress will be passed through as normal.
#
# [!] = optional operator '!' negates the behaviour when a
# list of applications is given. this marks the bind
# as 'Hotkey_Exclude', causing the bind to not work
# when the focused application is in the given list.
#
# [->] = optional operator '->' that marks this bind as
# 'passthrough'. this causes the key to be passed
# through to the system, instead of being consumed.
#
# <command> = command is executed through '$SHELL -c' and
# follows valid shell syntax. if the $SHELL environment
# variable is not set, it will default to '/bin/bash'.
# when bash is used, the ';' delimeter can be specified
# to chain commands.
#
# to allow a command to extend into multiple lines,
# prepend '\' at the end of the previous line.
#
# an EOL character signifies the end of the bind.
# NOTE(koekeishiya) Example of passthrough
# cmd - m -> : echo "alert and minimize window" | alerter -title Test passthrough -timeout 2
# NOTE(koekeishiya) Example of app list
# alt - e [
# iTerm2,
# Terminal,
# HyperTerm
# ]
# : echo "so this is how deep the rabbit hole goes.." |\
# alerter -title Test passthrough -timeout 2
# NOTE(koekeishiya) Example of negated app list
# alt - e [
# iTerm2,
# Terminal,
# HyperTerm
# ] !
# : echo "blue pill, i choose you!" |\
# alerter -title Test passthrough -timeout 2
# NOTE(koekeishiya) Modifier only binding
# left shift -> ( right shift -> )
# left cmd -> { right cmd -> }
# khd mod_trigger_timeout 0.1
# lshift : khd -p "shift - 8"
# rshift : khd -p "shift - 9"
# lcmd : khd -p "shift + alt - 8"
# rcmd : khd -p "shift + alt - 9"
# NOTE(koekeishiya) Bind mouse-buttons
# - button3 : khd -w "mouse-button 3 pressed"
# - button4 : khd -w "mouse-button 4 pressed"
# TODO(koekeishiya): possibly allow combined syntax such as
# [focus,ytd] + ctrl - f : khd -e "mode activate default"
# vi-mode for non-terminal applications
# remap left-control h/j/k/l -> arrow keys
ctrl - h ![Alacritty,iTerm2] : khd -p "- left"
ctrl - j ![Alacritty,iTerm2] : khd -p "- down"
ctrl - k ![Alacritty,iTerm2] : khd -p "- up"
ctrl - l ![Alacritty,iTerm2] : khd -p "- right"
# remap left-control 0 / 4 -> start / end of line
ctrl - 0 ![Alacritty,iTerm2] : khd -p "cmd - left"
ctrl - 4 ![Alacritty,iTerm2] : khd -p "cmd - right"
# remap left-control g / G -> start / end of text
ctrl - g ![Alacritty,iTerm2] : khd -p "cmd - up"
ctrl + shift - g ![Alacritty,iTerm2] : khd -p "cmd - down"
shift + ctrl - 0 ![Alacritty,iTerm2] : khd -p "shift + cmd - left"
shift + ctrl - 4 ![Alacritty,iTerm2] : khd -p "shift + cmd - right"
# remap left-control b / e -> start / end of word
ctrl - b ![Alacritty,iTerm2] : khd -p "alt - left"
ctrl - e ![Alacritty,iTerm2] : khd -p "alt - right"
shift + ctrl - b ![Alacritty,iTerm2] : khd -p "shift + alt - left"
shift + ctrl - e ![Alacritty,iTerm2] : khd -p "shift + alt - right"
ctrl - space ![Alacritty] : open /Applications/Alacritty.app
# set border color for different modes
khd mode default on_enter yabai -m config active_window_border_color 0xdd81a1c1 #blue
khd mode focus on_enter yabai -m config active_window_border_color 0xddeacb8a #yellow
khd mode swap on_enter yabai -m config active_window_border_color 0xddb48dac #purple
khd mode layout on_enter yabai -m config active_window_border_color 0xddbf6069 #red
# toggle between modes
ctrl - s : khd -e "mode activate focus"
focus + ctrl - s : khd -e "mode activate default"
swap + ctrl - s : khd -e "mode activate default"
layout + ctrl - s : khd -e "mode activate default"
focus - s : khd -e "mode activate swap"
focus - a : khd -e "mode activate layout"
layout - a : khd -e "mode activate focus"
swap - s : khd -e "mode activate focus"
### focus mode ###
focus - r : khd -e "reload" # reload config
# focus windows
focus - h : yabai -m window --focus west
focus - l : yabai -m window --focus east
focus - j : yabai -m window --focus south
focus - k : yabai -m window --focus north
focus - n : yabai -m window --focus next
focus - p : yabai -m window --focus prev
# focus monitors
focus - 1 : yabai -m display --focus 1
focus - 2 : yabai -m display --focus 2
# full screen
focus - f : yabai -m window --toggle native-fullscreen; khd -e "mode activate default"
### swap mode ###
# swap windows
swap - h : yabai -m window --swap west
swap - j : yabai -m window --swap south
swap - k : yabai -m window --swap north
swap - l : yabai -m window --swap east
swap - r : yabai -m space --rotate 90
# swap monitors
swap - 1 : yabai -m window --display 1; yabai -m display --focus 1
swap - 2 : yabai -m window --display 2; yabai -m display --focus 2
# swap desktops and follow
swap + shift - 1 : yabai -m window --space 1; khd -e "mode activate default"; khd -p "ctrl - 1"
swap + shift - 2 : yabai -m window --space 2; khd -e "mode activate default"; khd -p "ctrl - 2"
swap + shift - 3 : yabai -m window --space 3; khd -e "mode activate default"; khd -p "ctrl - 3"
swap + shift - 4 : yabai -m window --space 4; khd -e "mode activate default"; khd -p "ctrl - 4"
### layout mode ###
# switch layout
# Set all windows on active space back to normal
layout - b : yabai -m space --layout bsp; yabai -m query --windows --space \
| jq -re '.[] | select(."zoom-fullscreen" == 1) | .id' \
| xargs -I{} yabai -m window {} --toggle zoom-fullscreen; khd -e "mode activate default"
# Set all windows on active space to zoom-fullscreen - mimics switching layout to monocule
layout - z : yabai -m query --windows --space \
| jq -re '.[] | select(."zoom-fullscreen" == 0) | .id' \
| xargs -I{} yabai -m window {} --toggle zoom-fullscreen; khd -e "mode activate default"; \
yabai -m space --layout float; khd -e "mode activate default"
layout - f : yabai -m space --layout float; khd -e "mode activate default"
layout + shift - b : yabai -m space --balance; khd -e "mode activate default"
layout - p : yabai -m space --padding rel:6:6:10:10; yabai -m space --gap rel:5
layout + shift - p : yabai -m space --padding rel:-6:-6:-10:-10; ; yabai -m space --gap rel:-5