safari 1.0.0

Terminal UI for capturing and restoring Safari sessions on macOS
Documentation

safari

safari is a macOS-only terminal tool for capturing Safari windows and tabs, browsing saved backups in a TUI, and restoring a previous session with one command.

Features

  • Capture the current Safari session into structured JSON backups
  • Browse backups in a keyboard-first TUI with preview and detail views
  • Restore tabs grouped by Safari window instead of reopening everything flat
  • Keep backups in an application data directory while still reading legacy ~/.safari data
  • Use CLI commands for automation or the TUI for interactive workflows

Requirements

  • macOS with Safari installed
  • Rust toolchain if you want to build from source
  • Automation permission for Terminal/iTerm to control Safari through osascript

Install

cargo install --path .

Or run from source:

cargo run

Commands

# Launch the TUI
cargo run

# Capture the current Safari session
cargo run -- capture

# List saved backups
cargo run -- list

# Restore the latest backup
cargo run -- restore

# Restore the second backup shown by list
cargo run -- restore --index 2

Backward-compatible aliases are also kept:

cargo run -- dump
cargo run -- reopen

TUI Shortcuts

  • j / k or arrow keys: move between backups
  • enter: open full session details
  • n: capture a new backup
  • r: restore the selected backup
  • d: delete the selected backup with confirmation
  • f: refresh the backup list
  • q: quit

Inside details:

  • tab / h / l: switch between the window list and tab list
  • j / k: move inside the active pane
  • space: mark or unmark the current window
  • r: restore the current window
  • s: restore all marked windows
  • o: open only the selected URL
  • a: mark all windows or clear all marks
  • u: clear marked windows
  • Esc: go back

Data Storage

New backups are stored under the application data directory managed by directories:

  • ~/Library/Application Support/dev.lhpqaq.safari/sessions

Legacy backups stored in ~/.safari are still listed and can still be restored.

You can override the storage location when testing or packaging:

SAFARI_STORAGE_DIR=/tmp/safari cargo run -- list

Development

cargo fmt
cargo test