Frayo

← Guide

Code-aware Copy Text

Copy Text (⇧⌘2) reads text from your screen. When the text looks like code, Frayo keeps the indentation and blank lines, so you can paste it into an editor and run it.

Reading happens on your Mac, with the Vision framework built into macOS. Nothing is uploaded.

How to use it

  1. Press ⇧⌘2, or choose More Captures › Copy Text.
  2. Drag over the code.
  3. The code is on your clipboard. A message says how many lines were copied.

If Frayo decided the text is code, the message has a button: Copy as Code Block. It copies the same text fenced in triple backticks, with the language name, ready for Markdown:

def add(a, b): return a + b

Plain text is copied as plain lines. If the text holds exactly one web link, the message offers Open example.com instead.

What it does

How it decides it is code

It looks for symbols such as { } ( ) ; =, lines that end in ; { or ,, keywords such as func, def, class or import, and indented lines. Two or more of these signs mean code.

Languages

For the code block tag, Frayo guesses one of: Swift, Python, JavaScript, Go, Rust, Java, JSON, Bash, SQL. If nothing fits, the fence has no language.

Limits

Command line

frayo ocr <file> --code gives the same layout. See Command line.

Related: Text and QR codes, Code screenshots.