Skip to content

Liyue2341/SnapBack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SnapBack

Save & restore your entire Windows session with one command.
Because life's too short to reopen 20 windows after every reboot.

🇨🇳 中文  |  🇬🇧 English

Platform PowerShell License Stars


Quick Start

# Install (one-time)
git clone https://github.com/Liyue2341/SnapBack.git
cd SnapBack && .\install.ps1

# Use (every time)
snapback save        # before reboot
snapback restore     # after reboot - everything comes back

That's it. Restart your terminal after install. Works from anywhere.


What It Restores

🖥️ GUI apps (WeChat, browsers, etc.) • ⌨️ Terminal processes (Python, Node, SSH, ngrok) • 🤖 Claude Code (every instance, correct directory, multi-instance support) • 📁 All open File Explorer windows

Auto-start apps (PowerToys, OneDrive, Notion...) are automatically excluded.


Demo

PS> snapback save

  Capturing running processes...
  Capturing Explorer windows...

  Snapshot saved: 2026-03-28_143022
  Processes captured: 14
  Explorer folders:  4
PS> snapback restore

  [OK]   Weixin
  [OK]   claude @ D:\Projects\my-app
  [OK]   claude @ D:\Projects\backend (1/2)
  [OK]   claude @ D:\Projects\backend (2/2)
  [OK]   python @ D:\Projects\backend
  [OK]   ssh @ D:\Projects\server

  Restoring Explorer folders...
  [OK]   D:\Projects\my-app
  [OK]   D:\Projects\backend

  Restore complete: Restored 8, Folders 2

All Commands

Command What it does
snapback save Save current session
snapback restore Restore latest snapshot
snapback list List all snapshots
snapback show Show snapshot details
snapback save -Name dev Save with a custom name
snapback restore -Name dev Restore a specific snapshot
snapback delete -Name dev Delete a snapshot

How It Works (click to expand)

Save

  1. Queries running processes via WMI/CIM, filters out system/child/auto-start processes
  2. Detects real working directories by walking up the process tree to the parent shell and reading its CWD via the Windows PEB API (NtQueryInformationProcess)
  3. Captures open File Explorer windows via COM Shell.Application
  4. Saves everything as JSON

Restore

  1. GUI apps (browser, WeChat): skips if already running
  2. CLI tools (claude, python, node): matches by command-line arguments, supports multi-instance
  3. Relaunches each process with original arguments and working directory
  4. Reopens all Explorer folder windows

Architecture

SnapBack/
├── snapback.ps1       # CLI entry point
├── config.json        # Exclude lists & settings
├── install.ps1        # One-click global installer
└── lib/
    ├── Snapshot.ps1    # Process capture, CWD detection
    └── Restore.ps1    # Smart restore with duplicate detection
Configuration (click to expand)

Edit config.json to customize:

{
  "excludeProcesses": [...],       // System processes to ignore
  "autoStartProcesses": [...],     // Apps that restart on their own
  "excludeArgPatterns": [...],     // Filter by command-line patterns
  "maxSnapshots": 20,              // Auto-cleanup old snapshots
  "restoreDelayMs": 500,           // Delay between launches (ms)
  "confirmBeforeRestore": true     // Prompt before restoring
}
Known Limitations
  • Terminal scrollback / command history is not preserved — only running processes
  • Window positions and sizes are not restored (yet)
  • Windows Terminal tabs restore as individual processes, not grouped tabs
  • SSH sessions requiring interactive auth will prompt for credentials again

PRs and ideas welcome!


Support

If SnapBack saved you from the "15-minute workspace rebuild ritual":

Buy Me Some Tokens


MIT License • Built with frustration and PowerShell
⭐ Star if you've been there too

About

Save & restore your entire Windows session with one command. Because life's too short to reopen 20 windows after every reboot.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors