A lightweight Swift command-line tool to resize the frontmost window using macOS Accessibility APIs. Perfect for complementing Raycast's window management with precise horizontal and vertical resizing.
- Resize window width or height by relative pixel amounts
- Works with the currently frontmost/active window
- Maintains window position (adjusts coordinates to keep window centered)
- Supports both positive (increase) and negative (decrease) values
# Decrease width by 20px
window-resize w -20
# Increase width by 50px
window-resize width 50
# Decrease height by 30px
window-resize h -30
# Increase height by 100px
window-resize height 100make buildThe binary will be created in the bin/ directory as window-resize.
Install to ~/.local/bin (make sure this directory is in your $PATH):
make installThis will copy the binary to ~/.local/bin/window-resize.
window-resize [-v|--verbose] [w|width|h|height] [pixels]Or if running locally without installing:
./bin/window-resize [-v|--verbose] [w|width|h|height] [pixels]Raycast provides excellent window positioning (left half, right half, maximize, etc.) but lacks granular resizing. This tool fills that gap:
- Use Raycast to position a window (e.g., left half of screen)
- Use this tool to fine-tune the width:
window-resize w -50 - Perfect window size for your workflow
Example Raycast script:
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Increase Window Width
# @raycast.mode silent
#
# Optional parameters:
# @raycast.icon ↔️
# @raycast.packageName Window Management
BIN_PATH="$HOME/.local/bin"
WIDTH_INCREMENT="80" # pixels
"$BIN_PATH/window-resize" width "$WIDTH_INCREMENT" 1> /dev/null 2> /dev/nullCreate shell scripts or Raycast script commands for quick access:
# ~/.local/bin/shrink-width
#!/bin/bash
window-resize w -20
# ~/.local/bin/grow-height
#!/bin/bash
window-resize h 40Make sure ~/.local/bin is in your $PATH:
# Add to ~/.zshrc or ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"Then bind these scripts to keyboard shortcuts in your terminal or automation tool.
On first run, macOS will prompt you to grant Accessibility permissions to your terminal application (Terminal.app, iTerm2, Ghostty, etc.).
You can also manually grant permissions:
System Settings > Privacy & Security > Accessibility
Add and enable your terminal application in the list.