Skip to content

Paste the path of a file dropped on the window - #22

Merged
tkc merged 1 commit into
mainfrom
drop-file-paths
Sep 9, 2026
Merged

Paste the path of a file dropped on the window#22
tkc merged 1 commit into
mainfrom
drop-file-paths

Conversation

@tkc

@tkc tkc commented Sep 9, 2026

Copy link
Copy Markdown
Owner

What

Showing an agent a file meant typing its path out. Drag one onto the window and
the path is typed into the session instead, followed by a space, so several
dropped together line up as arguments. While a file is over the window the
bottom bar says what will happen.

This follows what orca does for its agent
prompt — "drag files or images straight into an agent prompt" — which is
where the request came from.

Quoting

Paths that need it are wrapped in single quotes. A space in a name would
otherwise split into two arguments, and a quote or a semicolon in one is worse
than that:

Dropped Sent
/Users/tkc/a.txt /Users/tkc/a.txt
/Users/tkc/My Documents/a.txt '/Users/tkc/My Documents/a.txt'
/tmp/it's here '/tmp/it'\''s here'
/tmp/資料.txt '/tmp/資料.txt'

Plain paths pass through untouched so the common case stays readable. If the
program has bracketed paste on, the path arrives as pasted text rather than as
typing.

Testing

Six new tests, 194 total: plain paths pass through, spaces are quoted, an
embedded single quote is closed and rejoined, nine kinds of character the shell
would act on (; $( ) backticks & | > * \ ") are quoted, a
Japanese path is quoted, and an empty path becomes an empty argument.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GvMacYD6T9EoWqc7C247Hr

Showing an agent a file meant typing its path out. Drag one onto the window
and the path is typed into the session instead, followed by a space, so
several dropped together line up as arguments. While a file is over the
window the bottom bar says what will happen.

Paths that need it are wrapped in single quotes — a space in a name would
otherwise split into two arguments, and a quote or a semicolon in one is worse
than that. Single quotes inside are closed and rejoined the usual way. Plain
paths are passed through untouched so the common case stays readable. If the
program has bracketed paste on, the path arrives as pasted text rather than as
typing.

Follows what orca does for its agent prompt, which is where the request came
from.

Adds six tests: plain paths pass through, spaces are quoted, an embedded
single quote is rejoined, nine kinds of character the shell would act on are
quoted, a Japanese path is quoted, and an empty path becomes an empty
argument.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GvMacYD6T9EoWqc7C247Hr
@tkc
tkc merged commit 56ae90d into main Sep 9, 2026
1 check passed
@tkc
tkc deleted the drop-file-paths branch September 9, 2026 11:13
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.

1 participant