Skip to content

Support path pasting in terminal - #48222

Merged
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
dunkmann00:terminal-mac-file-paste-2
May 5, 2026
Merged

Support path pasting in terminal#48222
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
dunkmann00:terminal-mac-file-paste-2

Conversation

@dunkmann00

Copy link
Copy Markdown
Contributor

This adds the functionality to support pasting the file path of an item when the copied item supports it. This mirrors the behavior of Terminal.app on macOS.

This only implements the functionality on macOS but could be extended to other platforms.

I find this convenient when I'm using Finder to navigate around the file system and I want to copy a directory or file path and put it in the terminal. You can copy the item from Finder and paste it into the terminal and it will write out the full path of the item, making it easy to change directories or provide path parameters to commands.

Release Notes:

  • Added path pasting functionality in terminal

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Feb 2, 2026
@dunkmann00

Copy link
Copy Markdown
Contributor Author

Hey @SomeoneToIgnore, not sure if this kind of thing would be your area of review but thought I'd reach out to see what you think?

@dunkmann00

Copy link
Copy Markdown
Contributor Author

I think that should address the error. My bad on that, it was on Windows so I didn't catch it locally.

@dunkmann00

Copy link
Copy Markdown
Contributor Author

Okay ran clippy locally so the test error should be fixed and I think windows should be good now.

@dunkmann00

Copy link
Copy Markdown
Contributor Author

Thought it might be a good idea to make a screen record to show the result of this PR. When copy/pasting in the terminal you can get the whole path (or just the text) to the item copied from Finder with both the keyboard and mouse:

path_pasting_screen_recording.mov

@ChristopherBiscardi

Copy link
Copy Markdown
Contributor

I pulled this locally and confirmed that it does succeed at implementing pasting filepaths from finder, so we should be able to merge this.

It will need to have main merged since there are a couple conflicts, and pass tests, but feel free to ping me and I'll make sure they're running so we can get this in.

@dunkmann00
dunkmann00 force-pushed the terminal-mac-file-paste-2 branch from fad76ef to fb92a8c Compare May 4, 2026 01:02
@dunkmann00

Copy link
Copy Markdown
Contributor Author

Hey @ChristopherBiscardi, sorry it took me so long to get back to this, but I've updated the PR.

There were a bunch of changes since I first made this, it actually is much simpler to do now since path handling has been added to the macOS clipboard. It also took advantage of ExternalPaths, which at the time I wasn't sure if that was what I should use to implement this, but looks like it probably was!

I haven't tested this on Windows, but I think it should work. If the tests show a problem or you see anything you'd like me to change I'd be happy to do so!

@dunkmann00

Copy link
Copy Markdown
Contributor Author

I was able to test this out on Windows and it works 👍

I think the error from CI doesn't have to do with this PR?

@ChristopherBiscardi

Copy link
Copy Markdown
Contributor

CI failure seemed like a networking issue. I kicked it off again.

@ChristopherBiscardi

Copy link
Copy Markdown
Contributor

Looks like the new implementation has some extra space and is wrapped in quotes:

image

vs Terminal behavior:

image

@dunkmann00

Copy link
Copy Markdown
Contributor Author

This is how drag and drop was handled already so I thought it would be better to have it be consistent. This way uses self.add_paths_to_terminal which is where the spaces and quotes are getting added. This also handles if you copy multiple files. And this is what drag and drop uses, so the behavior is consistent in zed, but different from the Terminal.app. But it does enable the same thing, the ability to copy a file and paste its path in zed's terminal.

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep that makes sense to me, thanks!

@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue May 5, 2026
Merged via the queue into zed-industries:main with commit 4b3c0cd May 5, 2026
49 of 51 checks passed
@dunkmann00

Copy link
Copy Markdown
Contributor Author

Thanks!

@dunkmann00
dunkmann00 deleted the terminal-mac-file-paste-2 branch May 5, 2026 15:13
ebaah46 pushed a commit to ebaah46/zed that referenced this pull request May 6, 2026
This adds the functionality to support pasting the file path of an item
when the copied item supports it. This mirrors the behavior of
`Terminal.app` on macOS.

This only implements the functionality on macOS but could be extended to
other platforms.

I find this convenient when I'm using Finder to navigate around the file
system and I want to copy a directory or file path and put it in the
terminal. You can copy the item from Finder and paste it into the
terminal and it will write out the full path of the item, making it easy
to change directories or provide path parameters to commands.

Release Notes:

- Added path pasting functionality in terminal
@m-ar-c

m-ar-c commented May 13, 2026

Copy link
Copy Markdown

Works on GNU/Linux too (debian) 👌

jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
This adds the functionality to support pasting the file path of an item
when the copied item supports it. This mirrors the behavior of
`Terminal.app` on macOS.

This only implements the functionality on macOS but could be extended to
other platforms.

I find this convenient when I'm using Finder to navigate around the file
system and I want to copy a directory or file path and put it in the
terminal. You can copy the item from Finder and paste it into the
terminal and it will write out the full path of the item, making it easy
to change directories or provide path parameters to commands.

Release Notes:

- Added path pasting functionality in terminal
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
This adds the functionality to support pasting the file path of an item
when the copied item supports it. This mirrors the behavior of
`Terminal.app` on macOS.

This only implements the functionality on macOS but could be extended to
other platforms.

I find this convenient when I'm using Finder to navigate around the file
system and I want to copy a directory or file path and put it in the
terminal. You can copy the item from Finder and paste it into the
terminal and it will write out the full path of the item, making it easy
to change directories or provide path parameters to commands.

Release Notes:

- Added path pasting functionality in terminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants