Skip to content

Instantly share code, notes, and snippets.

@zmre
Last active July 11, 2021 06:15
Show Gist options
  • Save zmre/b5e23a6ac1be92ce4f90390940d7f03a to your computer and use it in GitHub Desktop.
Save zmre/b5e23a6ac1be92ce4f90390940d7f03a to your computer and use it in GitHub Desktop.
My skhdrc file
# NOTE(koekeishiya): A list of all built-in modifier and literal keywords can
# be found at https://github.com/koekeishiya/skhd/issues/1
#
# A hotkey is written according to the following rules:
#
# hotkey = <mode> '<' <action> | <action>
#
# mode = 'name of mode' | <mode> ',' <mode>
#
# action = <keysym> '[' <proc_map_lst> ']' | <keysym> '->' '[' <proc_map_lst> ']'
# <keysym> ':' <command> | <keysym> '->' ':' <command>
# <keysym> ';' <mode> | <keysym> '->' ';' <mode>
#
# keysym = <mod> '-' <key> | <key>
#
# mod = 'modifier keyword' | <mod> '+' <mod>
#
# key = <literal> | <keycode>
#
# literal = 'single letter or built-in keyword'
#
# keycode = 'apple keyboard kVK_<Key> values (0x3C)'
#
# proc_map_lst = * <proc_map>
#
# proc_map = <string> ':' <command>
#
# string = '"' 'sequence of characters' '"'
#
# 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.
#
# -> = keypress is not consumed by skhd
#
# NOTE(koekeishiya): A mode is declared according to the following rules:
#
# mode_decl = '::' <name> '@' ':' <command> | '::' <name> ':' <command> |
# '::' <name> '@' | '::' <name>
#
# name = desired name for this mode,
#
# @ = capture keypresses regardless of being bound to an action
#
# 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.
# add an on_enter command to the default mode
:: default : chunkc border::color 0xff2255ff
# add a different border in launch mode and capture subsequent keys
:: launch @ : chunkc border::color 0xffcc23aa
# different border color for adjust mode
:: adjust : chunkc border::color 0xff23ccaa
# fn-space will bring launch mode. a second time cancels it.
default < fn - space ; launch
launch < fn - space ; default
# 0x35 = esc; escape in adjust or launch modes will go back to default
launch, adjust < 0x35 ; default
# Hotkeys in launch mode
launch < shift - f : open -na Finder ; skhd -k "0x35"
launch < f : open -a Firefox ; skhd -k "0x35"
launch < i : open -a iTerm ; skhd -k "0x35"
launch < v : open -a "Visual Studio Code" ; skhd -k "0x35"
launch < shift - m : skhd -k "0x35" ; /Applications/mpv.app/Contents/MacOS/mpv $(pbpaste); sleep 2 ; skhd -k "alt - p"
launch < shift - r : skhd -k "0x35" ; /usr/local/bin/brew services restart chunkwm
launch < r : skhd -k "0x35" ; open -a RamboxPro
launch < s : open -a Spotify ; skhd -k "0x35"
launch < b : open -a Bear ; skhd -k "0x35"
launch < e : open -a Evernote ; skhd -k "0x35"
launch < c : open -a Calendar ; skhd -k "0x35"
launch < 1 : open -a 1Password ; skhd -k "0x35"
launch < q : ~/Scripts/qtb.sh ; skhd -k "0x35"
# If launching kitty while a finder window is in the foreground, start in the dir of that finder window
launch < k [
"Finder" : skhd -k "0x35" ; /Applications/Kitty.app/Contents/MacOS/kitty --single-instance -d "$(osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)')"
* : skhd -k "0x35" ; /Applications/Kitty.app/Contents/MacOS/kitty --single-instance -d ~
]
launch < m [
"Finder" : skhd -k "0x35" ; /usr/local/bin/gvim "$(osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)')"
* : skhd -k "0x35" ; /usr/local/bin/gvim
]
# ctrl - `
#ctrl - 0x32 : osascript -e 'tell application "iTerm" to Activate'
# focus window
fn - h : chunkc tiling::window --focus west
fn - j : chunkc tiling::window --focus south
fn - k : chunkc tiling::window --focus north
fn - l : chunkc tiling::window --focus east
# equalize size of windows
fn - 0 : chunkc tiling::desktop --equalize
# swap windows
shift + fn - h : chunkc tiling::window --swap west
shift + fn - j : chunkc tiling::window --swap south
shift + fn - k : chunkc tiling::window --swap north
shift + fn - l : chunkc tiling::window --swap east
# move window
ctrl + fn - h : chunkc tiling::window --warp west
ctrl + fn - j : chunkc tiling::window --warp south
ctrl + fn - k : chunkc tiling::window --warp north
ctrl + fn - l : chunkc tiling::window --warp east
# make floating window fill left/right/top/bottom-half of screen
# OS doesn't let us use fn + arrow keys
alt + ctrl - left : chunkc tiling::desktop --layout float ; chunkc tiling::window --grid-layout 1:2:0:0:1:1
alt + ctrl - right : chunkc tiling::desktop --layout float ; chunkc tiling::window --grid-layout 1:2:1:0:1:1
alt + ctrl - up : chunkc tiling::desktop --layout float ; chunkc tiling::window --grid-layout 2:1:0:0:1:1
alt + ctrl - down : chunkc tiling::desktop --layout float ; chunkc tiling::window --grid-layout 2:1:0:1:1:1
# send window to desktop
fn - 1 : chunkc tiling::window --send-to-desktop 1
fn - 2 : chunkc tiling::window --send-to-desktop 2
fn - 3 : chunkc tiling::window --send-to-desktop 3
fn - 4 : chunkc tiling::window --send-to-desktop 4
fn - 5 : chunkc tiling::window --send-to-desktop 5
fn - 6 : chunkc tiling::window --send-to-desktop 6
fn - 7 : chunkc tiling::window --send-to-desktop 7
fn - 8 : chunkc tiling::window --send-to-desktop 8
fn - 9 : chunkc tiling::window --send-to-desktop 9
# send window to monitor and follow focus
fn - z : chunkc tiling::window --send-to-monitor 1; chunkc tiling::monitor -f 1
fn - x : chunkc tiling::window --send-to-monitor 2; chunkc tiling::monitor -f 2
# resize window
fn - a : chunkc tiling::window --use-temporary-ratio 0.05 --adjust-window-edge west; chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge east
fn - s : chunkc tiling::window --use-temporary-ratio 0.05 --adjust-window-edge south; chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge north
fn - w : chunkc tiling::window --use-temporary-ratio 0.05 --adjust-window-edge north; chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge south
fn - d : chunkc tiling::window --use-temporary-ratio 0.05 --adjust-window-edge east; chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge west
# rotate tree
alt - r : chunkc tiling::desktop --rotate 90
# mirror tree y-axis
alt - y : chunkc tiling::desktop --mirror vertical
# mirror tree x-axis
alt - x : chunkc tiling::desktop --mirror horizontal
# toggle desktop offset
alt - a : chunkc tiling::desktop --toggle offset
# toggle window fullscreen
alt - f : chunkc tiling::window --toggle fullscreen
# toggle window native fullscreen
shift + alt - f : chunkc tiling::window --toggle native-fullscreen
# toggle window parent zoom
alt - d : chunkc tiling::window --toggle parent
# toggle window split type
alt - e : chunkc tiling::window --toggle split
# float / unfloat window and center on screen
alt - t : chunkc tiling::window --toggle float;\
chunkc tiling::window --grid-layout 4:4:1:1:2:2
# toggle sticky
alt - s : chunkc tiling::window --toggle sticky
# toggle sticky, float and resize to picture-in-picture size
alt - p : chunkc tiling::window --toggle sticky;\
chunkc tiling::window --grid-layout 5:5:4:0:1:1
# change layout of desktop -- toggle three ways
fn - m : M=$(chunkc tiling::query --desktop mode) ;\
if [[ "$M" == "float" ]] ; then \
chunkc tiling::desktop --layout monocle ;\
elif [[ "$M" == "bsp" ]] ; then \
chunkc tiling::desktop --layout float ;\
else chunkc tiling::desktop --layout bsp ; fi
fn + shift - q : chunkc tiling::desktop --serialize ~/.chunkwm_layouts/dev_q
fn - q : chunkc tiling::desktop --deserialize ~/.chunkwm_layouts/dev_q
fn + shift - e : chunkc tiling::desktop --serialize ~/.chunkwm_layouts/dev_e
fn - e : chunkc tiling::desktop --deserialize ~/.chunkwm_layouts/dev_e
# clear border when doing screenshot
cmd + shift - 4 -> : chunkc border::clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment