Skip to content

swift1337/macos-window-resize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MacOS Window Resize Tool

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.

Features

  • 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

Examples

# 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 100

Building

make build

The binary will be created in the bin/ directory as window-resize.

Installation

Install to ~/.local/bin (make sure this directory is in your $PATH):

make install

This will copy the binary to ~/.local/bin/window-resize.

Usage

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]

Use Cases

With Raycast

Raycast provides excellent window positioning (left half, right half, maximize, etc.) but lacks granular resizing. This tool fills that gap:

  1. Use Raycast to position a window (e.g., left half of screen)
  2. Use this tool to fine-tune the width: window-resize w -50
  3. 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/null

Keyboard Shortcuts

Create 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 40

Make 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.

Permissions

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.

About

Resize mac os windows vertically or horizontally

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors