Skip to content

Instantly share code, notes, and snippets.

@tpreviero
Last active July 18, 2023 06:37
Show Gist options
  • Save tpreviero/ff0b3166c7a73005d3b8e1908be493d5 to your computer and use it in GitHub Desktop.
Save tpreviero/ff0b3166c7a73005d3b8e1908be493d5 to your computer and use it in GitHub Desktop.
# Uses yabai to create a 3x3 matrix of spaces on MacOs with wrap-around through skhd mappings
cmd + lctrl - up : yabai -m space --focus `yabai -m query --spaces --display | jq 'nth(index(map(select(."has-focus" == true))) - 3).index'`
cmd + lctrl - down : yabai -m space --focus `yabai -m query --spaces --display | jq 'nth((index(map(select(."has-focus" == true))) + 3) % 9).index'`
cmd + lctrl - right : yabai -m space --focus `yabai -m query --spaces --display | jq '((nth((index(map(select(."has-focus" == true))))).index / 3 | ceil - 1)*3)+(nth((index(map(select(."has-focus" == true))))).index%3)+1'`
cmd + lctrl - left : yabai -m space --focus `yabai -m query --spaces --display | jq '((nth((index(map(select(."has-focus" == true))))).index / 3 | ceil - 1)*3)+((nth((index(map(select(."has-focus" == true))))).index%3)+1)%3+1'`
lshift + cmd + lctrl - up : yabai -m window --space `yabai -m query --spaces --display | jq 'nth(index(map(select(."has-focus" == true))) - 3).index'` && yabai -m space --focus `yabai -m query --spaces --display | jq 'nth(index(map(select(."has-focus" == true))) - 3).index'`
lshift + cmd + lctrl - down : yabai -m window --space `yabai -m query --spaces --display | jq 'nth((index(map(select(."has-focus" == true))) + 3) % 9).index'` && yabai -m space --focus `yabai -m query --spaces --display | jq 'nth((index(map(select(."has-focus" == true))) + 3) % 9).index'`
lshift + cmd + lctrl - right : yabai -m window --space `yabai -m query --spaces --display | jq '((nth((index(map(select(."has-focus" == true))))).index / 3 | ceil - 1)*3)+(nth((index(map(select(."has-focus" == true))))).index%3)+1'` && yabai -m space --focus `yabai -m query --spaces --display | jq '((nth((index(map(select(."has-focus" == true))))).index / 3 | ceil - 1)*3)+(nth((index(map(select(."has-focus" == true))))).index%3)+1'`
lshift + cmd + lctrl - left : yabai -m window --space `yabai -m query --spaces --display | jq '((nth((index(map(select(."has-focus" == true))))).index / 3 | ceil - 1)*3)+((nth((index(map(select(."has-focus" == true))))).index%3)+1)%3+1'` && yabai -m space --focus `yabai -m query --spaces --display | jq '((nth((index(map(select(."has-focus" == true))))).index / 3 | ceil - 1)*3)+((nth((index(map(select(."has-focus" == true))))).index%3)+1)%3+1'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment