Skip to content

Finder-style overwrite protection + auto-refreshing picker#26

Merged
neilberkman merged 10 commits intomainfrom
feature/finder-style-overwrite-protection
Jan 11, 2026
Merged

Finder-style overwrite protection + auto-refreshing picker#26
neilberkman merged 10 commits intomainfrom
feature/finder-style-overwrite-protection

Conversation

@neilberkman
Copy link
Owner

Pasty: Finder-style overwrite protection

Pasty now uses macOS Finder's duplicate naming instead of silently overwriting files.

  • photo.pngphoto 2.pngphoto 3.png
  • READMEREADME 2README 3
  • file.tar.gzfile.tar 2.gz

Add --force / -f to override and allow overwriting when desired.

Clippy picker: Auto-refresh

The interactive picker now watches Downloads/Desktop directories and automatically refreshes when new files appear.

  • Uses fsnotify for real-time file system monitoring
  • New files appear within ~1 second
  • Cursor stays on the file you were looking at (by name, not index) to prevent accidental selection

Fixes #25

@ktowen
Copy link

ktowen commented Jan 8, 2026

Hello, any idea when this PR might get released?

When pasting files, pasty now uses macOS Finder's duplicate naming convention
instead of silently overwriting existing files.

Naming format follows Finder exactly:
- photo.png → photo 2.png → photo 3.png
- README → README 2 → README 3
- file.tar.gz → file.tar 2.gz (space before number, only last extension)

Applies to all paste operations:
- Text content pasting
- Image data pasting
- File reference copying

Fixes #25
Users can now use --force (-f) to overwrite existing files instead of
automatically creating duplicates with Finder-style naming.

Default behavior (safe): Creates duplicates using Finder naming
  pasty photo.png  # creates photo 2.png if photo.png exists

With --force (override): Overwrites existing files
  pasty --force photo.png  # overwrites photo.png

Changes:
- Added Force field to PasteOptions struct
- Updated all paste functions to respect force flag
- Added -f/--force flag to pasty command
- Added tests for force flag behavior

Relates to #25
Added brief mentions of Finder-style duplicate naming and --force flag.
Users can now press 'r' while in the interactive picker to refresh
the file list. Useful when downloading files while the picker is open.

- Added refreshFunc callback to pickerModel
- Press 'r' to re-scan directories (recent downloads mode) or re-run search (spotlight mode)
- Preserves cursor position when possible after refresh
- Updated help text to show refresh key
The picker now watches Downloads/Desktop directories for new files and
automatically refreshes the list when files are added. No more pressing 'r'!

- Added fsnotify dependency for cross-platform FS events
- Picker monitors watched directories in background
- Auto-refreshes when Create events detected
- Works for recent downloads mode (watches directories)
- Spotlight mode doesn't watch (re-search isn't instant)
- Manual 'r' key still works as fallback

When you download a file while the picker is open, it appears
automatically within ~1 second.
Auto-monitoring already refreshes the list automatically when files are
added, so the manual 'r' key is unnecessary complexity.

Simpler is better.
When the file list auto-refreshes, keep the cursor on the same file
by name instead of by index. This prevents accidentally selecting a
newly appeared file if it appears where the cursor was positioned.

Example: User on 'report.pdf' at position 3. New file 'download.zip'
appears at top. Cursor stays on 'report.pdf' (now at position 4)
instead of moving to 'download.zip' at position 3.

Prevents accidental selection when files appear during download.
New files that appear during auto-refresh are now highlighted in bold
yellow for 3 seconds, making them immediately visible to users.
.tar.gz, .tar.bz2, .tar.xz, .tar.zst now handled correctly:
- archive.tar.gz → archive 2.tar.gz (not archive.tar 2.gz)

Added splitExtension() helper to detect multi-part extensions.
@neilberkman neilberkman force-pushed the feature/finder-style-overwrite-protection branch from f5c7f53 to 426a85e Compare January 11, 2026 01:21
@neilberkman neilberkman merged commit ff5d34d into main Jan 11, 2026
@neilberkman neilberkman deleted the feature/finder-style-overwrite-protection branch January 11, 2026 01:21
@neilberkman
Copy link
Owner Author

Hello, any idea when this PR might get released?

@ktowen just released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Finder-style overwrite protection to pasty

2 participants