recent

package
v1.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile added in v1.2.0

func CopyFile(src, dst string) error

copyFile copies a single file CopyFile copies a file from src to dst, preserving permissions and creating directories as needed

func CopyFileToDestination added in v0.7.2

func CopyFileToDestination(srcPath, destPath string) error

CopyFileToDestination copies a file or directory to the specified destination

func GetBrowserDownloadDir

func GetBrowserDownloadDir() string

GetBrowserDownloadDir attempts to detect browser-specific download directories

func GetDefaultDownloadDirs

func GetDefaultDownloadDirs() []string

GetDefaultDownloadDirs returns common download directories on macOS

func IsArchive

func IsArchive(filename string) bool

IsArchive checks if a file is a common archive format

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses duration strings like "5m", "1h", "30s", "7d", "2 weeks ago"

func ParseRecentArgument added in v1.2.0

func ParseRecentArgument(arg string) (count int, maxAge time.Duration, err error)

ParseRecentArgument parses the argument to -r or -i flags Returns count (number of files) and maxAge (time duration) Examples:

  • "" or " " -> count=1, maxAge=0 (default)
  • "3" -> count=3, maxAge=0
  • "5m" -> count=0, maxAge=5 minutes (0 means all files in period)

Types

type ArchiveInfo

type ArchiveInfo struct {
	OriginalName string // e.g. "project.zip"
	FolderPath   string // e.g. "/Users/neil/Downloads/project/"
	Contents     []FileInfo
}

ArchiveInfo represents information about an auto-unarchived download

type FileInfo

type FileInfo struct {
	Path     string
	Name     string
	Size     int64
	Modified time.Time
	IsDir    bool
	MimeType string // MIME type of the file (empty for directories)
}

FileInfo represents a file with its metadata

func CopyMostRecentDownload

func CopyMostRecentDownload(maxAge time.Duration) (*FileInfo, error)

CopyMostRecentDownload finds the most recent download and copies it to clipboard This is the primary use case: "I just downloaded something, copy it to clipboard"

func CopyRecentDownloads

func CopyRecentDownloads(maxAge time.Duration, maxCount int) ([]FileInfo, error)

CopyRecentDownloads finds multiple recent downloads and copies them to clipboard This handles the case where multiple files were downloaded as a batch

func FindMostRecentFile

func FindMostRecentFile(opts FindOptions) (*FileInfo, error)

FindMostRecentFile finds the single most recent file

func FindRecentFiles

func FindRecentFiles(opts FindOptions) ([]FileInfo, error)

FindRecentFiles finds files matching the given criteria

func GetRecentDownloads added in v0.8.0

func GetRecentDownloads(config PickerConfig, maxCount int) ([]FileInfo, error)

GetRecentDownloads returns recent files for picker display

func PasteMostRecentDownload

func PasteMostRecentDownload(destination string, maxAge time.Duration) (*FileInfo, error)

PasteMostRecentDownload finds and copies the most recent download to destination This is the primary use case: "I just downloaded something, paste it here"

func PasteRecentDownloads

func PasteRecentDownloads(destination string, maxAge time.Duration, maxCount int) ([]FileInfo, error)

PasteRecentDownloads finds and copies multiple recent downloads to destination This handles batch downloads like "I downloaded 5 photos, paste them all"

func PickMultipleRecentDownloads added in v0.8.0

func PickMultipleRecentDownloads(config PickerConfig) ([]*FileInfo, error)

PickMultipleRecentDownloads is deprecated - use GetRecentDownloads instead

func PickRecentDownload

func PickRecentDownload(maxAge time.Duration) (*FileInfo, error)

func PickRecentDownloadWithConfig added in v0.8.0

func PickRecentDownloadWithConfig(config PickerConfig) (*FileInfo, error)

func (*FileInfo) Age added in v1.3.2

func (f *FileInfo) Age() time.Duration

Age returns the age of the file as a duration from now (always positive)

type FindOptions

type FindOptions struct {
	MaxAge         time.Duration
	MaxCount       int
	Directories    []string
	Extensions     []string
	ExcludeTemp    bool
	SmartUnarchive bool // Look inside auto-unarchived folders
}

FindOptions controls how recent files are discovered

func DefaultFindOptions

func DefaultFindOptions() FindOptions

DefaultFindOptions returns sensible defaults for finding recent files

type PickerConfig added in v0.8.0

type PickerConfig struct {
	MaxAge       time.Duration
	AbsoluteTime bool
}

PickRecentDownload returns a single recent download This handles the case where you want to select from multiple recent files

type PickerResult added in v0.8.0

type PickerResult struct {
	Files     []*FileInfo
	PasteMode bool // true if user pressed 'p' to copy & paste
}

PickerResult represents the result of an interactive file picker

func PickRecentDownloadsWithResult added in v0.8.0

func PickRecentDownloadsWithResult(config PickerConfig) (*PickerResult, error)

PickRecentDownloadsWithResult is deprecated - use GetRecentDownloads instead

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL