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
~/.safaridata - 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/kor arrow keys: move between backupsenter: open full session detailsn: capture a new backupr: restore the selected backupd: delete the selected backup with confirmationf: refresh the backup listq: quit
Inside details:
tab/h/l: switch between the window list and tab listj/k: move inside the active panespace: mark or unmark the current windowr: restore the current windows: restore all marked windowso: open only the selected URLa: mark all windows or clear all marksu: clear marked windowsEsc: 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