Skip to content

Instantly share code, notes, and snippets.

@shreewatsa
Last active March 15, 2023 07:44
Show Gist options
  • Save shreewatsa/648b2cff93c840a063651fea3171f921 to your computer and use it in GitHub Desktop.
Save shreewatsa/648b2cff93c840a063651fea3171f921 to your computer and use it in GitHub Desktop.
MacOS: skhd configuration file aka skhdrc

skhd config file location: ~/.config/skhd/skhdrc

Thinking behind these shortcuts:
Use 'cmd' key for all desktop,window,space related shortcuts. Here, cmd+alt is preferred to cmd+shift.
Use 'alt' key for all tmux related shortcuts.
Use 'ctrl', and leader key 'space' for vim related shortcuts.

Note: Most of the following shortcuts are configured for yabai.

#!/usr/bin/env sh

alt - return : open -a Alacritty

### Focus Space:                                  to left or right space.
cmd - h : yabai -m window --focus "$(yabai -m query --spaces --space prev | jq -r '."last-window"')" || yabai -m space --focus prev  # num_index, first, last, next, prev, recent.
cmd - l : yabai -m window --focus "$(yabai -m query --spaces --space next | jq -r '."first-window"')" || yabai -m space --focus next 


### Focus Display ie next monitor:
cmd - j : yabai -m display --focus recent


### Focus window:                                 to left or right window in the same workspace.
cmd - i : yabai -m window --focus west            # focus left window.
cmd - o : yabai -m window --focus east            # focus right window.

### Swap window:                                  within space.
cmd + alt - i : yabai -m window --swap west
cmd + alt - o : yabai -m window --swap east       # east, west, north, south

### resize window:
cmd + alt + shift - i : yabai -m window --resize left:-20:0  # top:0:-20 , top:0:20
cmd + alt + shift - o : yabai -m window --resize left:20:0

### Move window:    within space.
# shift + alt + ctrl - h : yabai -m window --warp west


### move window and focus desktop
# shift + alt - 1 : yabai -m window --space 1; yabai -m space --focus 1
cmd + shift - 1 : yabai -m window --space 1; yabai -m space --focus 1
cmd + shift - 2 : yabai -m window --space 2; yabai -m space --focus 2
cmd + shift - 3 : yabai -m window --space 3; yabai -m space --focus 3
cmd + shift - 4 : yabai -m window --space 4; yabai -m space --focus 4
cmd + shift - 5 : yabai -m window --space 5; yabai -m space --focus 5
cmd + shift - 6 : yabai -m window --space 6; yabai -m space --focus 6
cmd + shift - 7 : yabai -m window --space 7; yabai -m space --focus 7
cmd + shift - 8 : yabai -m window --space 8; yabai -m space --focus 8
cmd + shift - 9 : yabai -m window --space 9; yabai -m space --focus 9
cmd + shift - 0 : yabai -m window --space 10; yabai -m space --focus 10

# toggle window fullscreen zoom
cmd - f : yabai -m window --toggle zoom-fullscreen
cmd + alt - f : yabai -m window --toggle native-fullscreen

# balance size of windows
cmd + alt - 0 : yabai -m space --balance

# rotate tree
cmd + alt - r : yabai -m space --rotate 90
cmd + alt - y : yabai -m space --mirror y-axis
cmd + alt - x : yabai -m space --mirror x-axis

### toggle Sticky
cmd + alt - s : yabai -m window --toggle sticky;\
          yabai -m window --toggle topmost;\
          yabai -m window --toggle pip

### toggle Gaps
cmd + alt - g : yabai -m space --toggle padding; yabai -m space --toggle gap

# float / unfloat window and center on screen
cmd + alt - t : yabai -m window --toggle float;\
          yabai -m window --grid 4:4:1:1:2:2

# toggle window split type
cmd + alt - e : yabai -m window --toggle split

### create desktop, move window and follow focus - uses jq for parsing json (brew install jq)
# shift + alt - n : yabai -m space --create && \
#                    index="$(yabai -m query --spaces --display | jq 'map(select(."native-fullscreen" == 0))[-1].index')" && \
#                    yabai -m window --space "${index}" && \
#                    yabai -m space --focus "${index}"

### Destroy desktop : Only destroy the space but not with windows.
# cmd + shift - q : yabai -m space --destroy

# fast focus desktop
# cmd - tab : yabai -m space --focus recent

### send window to monitor and follow focus
# cmd + alt - n : yabai -m window --display next; yabai -m display --focus next
# cmd + alt - p : yabai -m window --display previous; yabai -m display --focus previous

# cmd - space : /Users/logpoint/.config/commons/popup.sh /Users/logpoint/.config/commons/launcher.sh

## Reference
## increase window size
# shift + alt - a : yabai -m window --resize left:-20:0
# shift + alt - s : yabai -m window --resize bottom:0:20
# shift + alt - w : yabai -m window --resize top:0:-20
# shift + alt - d : yabai -m window --resize right:20:0

## decrease window size
# shift + cmd - a : yabai -m window --resize left:20:0
# shift + cmd - s : yabai -m window --resize bottom:0:-20
# shift + cmd - w : yabai -m window --resize top:0:20
# shift + cmd - d : yabai -m window --resize right:-20:0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment