spark magic — System Utilities

System-level utilities: DNS flush, directory cleaning, dotfile deploy, mirror switching.

Quick Reference

spark magic flush-dns                         # Flush the DNS cache
spark magic clean [-m node|python]            # Clean node_modules and .venv
spark magic copy-config [<user@host:path>]    # Deploy built-in nvim + ghostty templates

# Mirror switching (pip / go / node share the same subcommands)
spark magic <pip|go|node> list                # List available mirrors
spark magic <pip|go|node> use <name>          # Switch mirror
spark magic <pip|go|node> current             # Show the current configuration

spark magic flush-dns

Flush the system DNS cache.

spark magic flush-dns

Auto-detects the OS and runs the appropriate command:

  • macOS: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • Windows: ipconfig /flushdns
  • Linux: sudo systemctl restart systemd-resolved

spark magic clean

Recursively clean node_modules and .venv directories under a project directory.

spark magic clean                             # Clean both
spark magic clean -m node                     # Only node_modules
spark magic clean -m python                   # Only .venv
Flag Short Default Description
-m, --mode Clean mode: node, python (default: both)

Behavior:

  • Scans the directory passed via --path (default: current directory)
  • Automatically skips .git directories
  • Lists every directory that was cleaned

spark magic copy-config

Deploy the Neovim and Ghostty config templates that are embedded at build time to a destination. Template sources live in internal/templates/dotfiles/ and are packaged into the binary via //go:embed.

spark magic copy-config                       # Deploy to the local ~/.config/{nvim,ghostty}
spark magic copy-config user@192.168.1.100:~/ # Deploy over SSH to a remote host
spark magic copy-config /mnt/usb/backup/      # Deploy to a custom local path

Behavior:

  • With no argument, writes to the local default paths (~/.config/nvim/, ~/.config/ghostty/)
  • Prefers rsync; falls back to cp for local targets
  • Templates are a starting point — edit internal/templates/dotfiles/ and rebuild to customize

spark magic pip

Manage Python pip mirrors.

spark magic pip list                          # List every available mirror
spark magic pip use tsinghua                  # Switch to the Tsinghua mirror
spark magic pip use default                   # Restore the official index
spark magic pip current                       # Show the current mirror

Available mirrors:

Config file location: ~/.pip/pip.conf


spark magic go

Manage Go module proxy settings.

spark magic go list                           # List every available proxy
spark magic go use goproxy                    # Switch to goproxy.cn
spark magic go use default                    # Restore the official proxy
spark magic go current                        # Show the current proxy

Available proxies:

Configured via: go env -w GOPROXY=<url>


spark magic node

Manage the Node.js npm registry.

spark magic node list                         # List every available registry
spark magic node use taobao                   # Switch to the Taobao registry
spark magic node use default                  # Restore the official registry
spark magic node current                      # Show the current registry

Available registries:

Configured via: npm config set registry <url>