Just watched a YouTube video: macOS: Essential Productivity Hacks for Developers, which introduced shortcuts, virtual desktops, and window management tools. One tool that perfectly fits my needs is skhd: GitHub link.
With so many apps open at once, finding a specific app window can take time without better window management. For instance, during penetration testing, I might need to frequently switch between the terminal, Burp Suite, browser, notes, Visual Studio, and IM apps. This frequent toggling wastes a lot of time.
Install
After installation, it will write a plist file to ensure it starts automatically on boot.
brew install koekeishiya/formulae/skhd
skhd --install-service
skhd --start-service
According to the README, the configuration file is read from one of the following paths:
- $XDG_CONFIG_HOME/skhd/skhdrc
- $HOME/.config/skhd/skhdrc
- $HOME/.skhdrc
Setup
Create a .skhdrc file in your home directory.
The most practical setup involves defining hotkeys in the following format:
hotkey = <mode> '<' <action> | <action>
mode = 'name of mode' | <mode> ',' <mode>
keysym = <mod> '-' <key> | <key>
action = <keysym> ':' <command>
For example, using alt + c to open Visual Studio Code looks like this:
alt - c : open -a 'Visual Studio Code'
alt - t : open -a 'Microsoft Teams'
cmd + shift - e : /path/to/your/script.sh #執行特定 script
Many users combine skhd with yabai for advanced window management. However, since many window management tools require disabling SIP (System Integrity Protection), I decided not to consider it for now.
Advanced Use: Modes You can define multiple layers of hotkeys, similar to how Vim modes work. For example:
# Create a new mode
:: pentest
# Define mode switching
alt - p ; pentest
# Enable hotkeys within a specific mode
pentest < b : open -a 'Burp Suite Professional' | skhd -k 'escape'
# Return to default mode
pentest < escape ; default
You can also set up hotkeys that work only within a specific application. After modifying the config file, reload it with: skhd -v
Debug
If you encounter issues, you can stop the service, enable verbose mode, and then restart the service after making changes.
skhd --stop-service
skhd -V