A fast, zero-dependency Swift command-line utility that snaps and resizes active macOS windows using fractional screen coordinates.
macOS includes a native "Resize Window" action in the Shortcuts app, and power users frequently write AppleScript via System Events to manage window layouts. However, both of these native approaches fail on non-standard, custom application frameworks—most notably Adobe Creative Cloud apps (Audition, Photoshop, Premiere), Steam, and custom graphics canvases.
When targeting these apps, AppleScript and Shortcuts typically fail in two ways:
- Silent Failure: The command executes without error, but the window does not move because high-level AppleScript IPC wrappers are ignored by the app's custom UI engine.
- Crash Errors: The script throws
System Events got an error: Can't get window 1... Invalid index.because non-native apps report0standard Cocoa (NSWindow) window objects to macOS.
tile bypasses high-level AppleScript wrappers entirely. Built directly on top of macOS's native ApplicationServices framework, tile fetches the frontmost process ID and updates its low-level C Accessibility attributes (AXUIElementSetAttributeValue) directly. This forces even the most stubborn non-native application frames to instantly resize and reposition without requiring a heavy third-party menu-bar daemon running in the background.
tile is written in Swift and uses system libraries built into macOS. You do not need Homebrew, Python, or external package managers.
Save the Swift script code locally as tile.swift.
Open Terminal in the directory containing tile.swift and compile with optimizations enabled:
swiftc -O tile.swift -o tile
Move the binary to /usr/local/bin so it can be called from anywhere:
sudo mv tile /usr/local/bin/tile
which tile
Expected output: /usr/local/bin/tile
tile accepts four fractional parameters representing percentages of your display bounds (from 0.0 to 1.0):
tile <X_Position> <Y_Position> <Width_Fraction> <Height_Fraction>
| Layout | Command | Description |
|---|---|---|
| Left Half | tile 0 0 0.5 1 |
Left 50% of screen, full height |
| Right Half | tile 0.5 0 0.5 1 |
Right 50% of screen, full height |
| Top Left Quarter | tile 0 0 0.5 0.5 |
Top-left 25% of screen |
| Top Right Quarter | tile 0.5 0 0.5 0.5 |
Top-right 25% of screen |
| Bottom Left Quarter | tile 0 0.5 0.5 0.5 |
Bottom-left 25% of screen |
| Bottom Right Quarter | tile 0.5 0.5 0.5 0.5 |
Bottom-right 25% of screen |
| Maximize | tile 0 0 1 1 |
Fills 100% of available screen |
Follow these steps to map tile commands to global keyboard shortcuts using the native macOS Shortcuts app:
- Open the Shortcuts app on your Mac.
- Click + in the toolbar to create a new shortcut.
- In the right-hand action sidebar, search for Run Shell Script and drag it into the shortcut editor.
- Replace the default
echo "Hello World"text with your desired command (e.g.,/usr/local/bin/tile 0 0 0.5 0.5). - In the right-hand sidebar, click the Shortcut Details icon (the
ibadge or sliders icon) and check Use as Quick Action. - Click Add Keyboard Shortcut and press your desired hotkey combination (e.g.,
Option + Shift + Up Arrow). - Name the shortcut (e.g.,
Tile Top Left) and close the window.
When running a shortcut for the first time, macOS may prompt you to grant Accessibility access. Navigate to System Settings > Privacy & Security > Accessibility and ensure Shortcuts (and Terminal, if testing via command line) is toggled On.