PocketCommander

· Codeberg.org

8 min read Original article ↗

Pocket Commander

A two-pane, Norton Commander style file manager for moving music, photos and any other files between a Mac and an Android phone over USB with adb. Left pane: Mac. Right pane: phone. It is a Python curses program running inside a retro green-on-black terminal window.

Pocket Commander: Mac folders on the left, the phone on the right

Why

macOS has no built-in way to browse an Android phone, and Google no longer offers Android File Transfer. Most tools that replaced it use MTP, which many people find slow and unreliable for large copies. Pocket Commander uses adb instead. Copies are incremental, so copying an album a second time sends only what changed. Photos keep their dates, and a stopped copy to the Mac leaves no half-written files. Nothing goes over Wi-Fi or the cloud, and you don't need an account.

Download

Get the latest Pocket-Commander-<version>.dmg from Releases, open it and drag Pocket Commander to Applications. The app is signed and notarized, and Python and adb are included, so nothing else needs to be installed. It runs on Apple Silicon Macs with macOS 12 or later.

On the phone, turn on USB debugging once: Settings > About phone, tap Build number seven times, then Settings > System > Developer options > USB debugging. Connect the cable and accept the "Allow USB debugging?" prompt on the phone.

Releases and trust

Pocket Commander can read, copy and delete files on your phone, so it's fair to ask what the download really contains. Ways to check:

  • The download is the published one. Compare shasum -a 256 Pocket-Commander-<version>.dmg with the SHA-256 in the release notes.
  • Who signed it, and that Apple notarized it. spctl -a -vv "/Applications/Pocket Commander.app" should print source=Notarized Developer ID and origin=Developer ID Application: Lukas Spieker (VQ325QFM94). Notarization means Apple scanned the app for known malware; it isn't a review of the code.
  • It asks macOS for no extra rights. codesign -d --entitlements - "/Applications/Pocket Commander.app" lists no entitlements: the hardened runtime with no exceptions.
  • It doesn't go online. The app opens two connections, both inside your Mac: adb's server on 127.0.0.1:5037, which talks to the phone over USB, and the window's link to the file manager on a random 127.0.0.1 port. That link answers only the app's own window, which proves itself with a secret made fresh at every start, so web pages and other apps can't use it. The window loads only files inside the app. An outbound firewall such as LuLu shows every connection.
  • What it was built from. The release notes name the commit, the Python and PyInstaller versions, and the bundled adb version. Every package in the app is pinned with its hash in requirements-release.lock. Before each build, ./check-release.sh checks the source for networking code, and the build checks that the bundled adb carries Google's signature. Unlike the source, a PyInstaller build isn't yet byte-for-byte reproducible, so you can rebuild a release from its tag but can't compare the two file by file.

Running from source

You need Python 3.9 or later, uv and adb, either from the Android SDK (~/Library/Android/sdk/platform-tools/adb) or on PATH (brew install android-platform-tools). Releases are built with Python 3.13.

uv venv
uv pip install -r requirements.txt
.venv/bin/python retro-wrapper.py          # the retro window
.venv/bin/python pocket-commander-tui.py   # or in any terminal

The TUI itself needs only the standard library and adb; requirements.txt (pywebview, websockets, pyobjc) is for the window. There is also a plain shell CLI: ./pocket-commander.sh push <file-or-folder>, photos, pull.

Keys

Key Action
Tab, Left, Right switch pane
Enter / Backspace open folder / go up (cursor lands on the folder you left)
/ jump to a name by typing: the first name starting with the text, ignoring case, else the first containing it. Up/Down: other matches, Enter: stay, Esc: back
Space mark or unmark for a multi-item copy
C copy the selection to the other pane. A dialog lists every item with kind, file count and size before anything happens, and any phone files the copy would replace
M move the selection from the phone to the Mac: copy, then delete from the phone each file whose copy on the Mac has the same checksum. Only Y confirms
D delete the selection on the phone. Only Y confirms; Enter and Esc keep the files
N or F7 new folder in the current pane
E or F6 rename the item under the cursor. A new spelling of the same name ("Kind of blue" to "Kind of Blue") works too
P mirror the phone's DCIM to ~/Desktop/PhoneDCIM, skipping photos already copied
O reveal the Mac item in Finder
R refresh both panes
Esc cancel a running transfer, or clear marks
? help
Q quit

The line above the key bar always shows what C will copy and where, for example C copies Kind of Blue [folder, 9 files, 312 MB] -> Xiaomi 15T: /sdcard/Music/.

Behaviour worth knowing

  • Copies are incremental. Mac to phone uses adb push --sync per file, so unchanged files are skipped and progress is per file. Phone to Mac keeps each file's date from the phone and skips files that already exist with the same size, unless the phone's file is newer (edited since). Files arrive under a hidden .name.part and are renamed when complete, and Esc stops even a large video mid-copy.
  • A Mac file is never overwritten. If the phone has a newer version, the Mac's old file goes to the Trash first. A Mac file that is newer than the phone's and differs from it, such as a photo you rotated in Preview, is kept and the phone's version is not copied; the status line counts these as "kept changed on the Mac".
  • The phone has no Trash, so a copy to the phone that would replace files there lists them first, with both dates, and marks those that are newer on the phone. Then only Y replaces them, K copies everything else and leaves the phone's versions, and Enter or Esc cancels. Like adb push --sync, it counts a phone file as unchanged when its date matches the Mac's.
  • Hidden files (.DS_Store, .trashed-*, .thumbnails) are never shown or copied.
  • Folders are pushed file by file, which avoids adb's habit of nesting Album/Album when a folder is pushed a second time.
  • Plugging the phone in or out is detected within a couple of seconds.
  • Move only goes from the phone to the Mac; the app never deletes Mac files. After the copy it lists the phone folder again and deletes only files whose copy on the Mac has the same size and MD5 checksum and has been flushed to disk, so a failed file, a photo taken during the copy, or a different file that happens to share a name stays on the phone, and a power cut right after a move can't lose photos. Folders the move emptied are removed; a folder that still holds Android's hidden .trashed-* files stays.
  • Each pane header shows the free space on that side. If a copy is larger than the free space, the copy dialog says so and only Y starts it (unchanged files already there are skipped, so a re-copy may still fit).
  • The last Mac and phone folders are remembered in ~/Library/Application Support/Pocket Commander/state.json.
  • Every transfer and delete is logged to ~/Library/Logs/Pocket Commander.log.
  • Transfers longer than ten seconds end with a macOS notification and a sound.
  • xterm.js and the VT323 font are bundled in assets/, and the window never loads anything from the internet, so it works offline.

Environment overrides: POCKET_COMMANDER_MAC_START, POCKET_COMMANDER_PHONE_START (start folders) and POCKET_COMMANDER_NO_STATE=1 (do not save state). The tests use these.

Files

  • pocket-commander-tui.py the curses UI
  • photo_sync.py incremental phone-to-Mac folder mirror, also a CLI
  • retro-wrapper.py native window: pywebview + xterm.js + a pty bridge over a local WebSocket
  • retro-terminal.html the terminal page and CRT styling
  • pocket-commander.sh plain shell CLI
  • launcher.c and make-app.sh build a launcher app that runs these sources (see docs/maintaining.md)
  • make-release.sh builds the signed, notarized DMG for Releases
  • check-release.sh checks the source for networking code before each release
  • requirements-release.lock every package in the release, pinned with hashes
  • publish-release.sh publishes it as a Codeberg release
  • CHANGELOG.md release notes, one section per version
  • assets/ bundled xterm.js, font, and app icons
  • tests/ unit tests and the pty smoke test

Testing

  • .venv/bin/python -m unittest discover tests covers the phone-free logic (copy, move and overwrite rules against a fake adb) and the window's bridge (tests/test_bridge.py: it refuses connections without the secret path, from web pages, and a second one at a time).
  • .venv/bin/python tests/smoke_pty.py drives the real TUI through a pty with a phone attached (pyte comes from requirements-dev.txt). It copies a temporary album to /sdcard/Download/.mt-smoke, re-copies it to confirm skipping, edits a file on the phone and checks the replace warning (Enter cancels, K keeps the phone's file, Y replaces it), deletes the album, pulls a file back, and cleans up. It never touches /sdcard/Music.
  • ./check-release.sh checks the source for networking code, the bridge's lock and the page's Content-Security-Policy.

Licence

Pocket Commander is free software under the GNU General Public License, version 3 (see LICENSE). Bundled third-party parts keep their own licences: xterm.js (MIT) and the VT323 font (SIL Open Font License 1.1), with texts in assets/licenses/, and in the release build adb from Android platform-tools (Apache 2.0), whose notice ships inside the app as adb-NOTICE.txt.

Feedback

Bug reports and ideas are welcome in Issues.