Skip to content

Feat: native clipboard (using arboard) - #17572

Merged
fdncred merged 17 commits into
nushell:mainfrom
fmotalleb:feat/native-clipboard
Feb 20, 2026
Merged

fdncred merged 17 commits into
nushell:mainfrom
fmotalleb:feat/native-clipboard

Conversation

@fmotalleb

@fmotalleb fmotalleb commented Feb 16, 2026 •

Copy link
Copy Markdown
Contributor

Cross-platform clipboard command

This PR integrates nu_plugin_clipboard into Nushell as a built-in internal command.

Migrating from an external plugin required several changes across the codebase and internal APIs. Because of this, the current implementation may not be completely stable and will likely need further testing and debugging.

This PR prioritizes integration over stability, and additional fixes are expected in follow-up work.

Examples:

# Copy data to the clipboard
~> "data" | clip copy

# Pass through the copied data
~> "data" | clip copy --show | save out.txt

# Retrieve data from the clipboard
~> clip paste

Like the original plugin, it can automatically convert objects and arrays to and from JSON.
This behavior can be disabled using the --raw flag on the paste subcommand.
However, to copy a raw value, you must explicitly cast it to a string.

Note: this feature could be removed to keep the command simpler and aligned with a single-responsibility design, but it's a nice-to-have thing.

Closes: #16242

Release notes summary - What our users need to know

Cross-platform native clipboard commands

Two new commands were added clip copy and clip paste. They replace the implementation of std/clip with a native implementation and are now built-in commands that are available all the time.

# Copy data to the clipboard
~> "data" | clip copy

# Pass through the copied data
~> "data" | clip copy --show | save out.txt

# Retrieve data from the clipboard
~> clip paste

Tasks after merging

Comment thread crates/nu-cmd-clip/src/utils/json.rs Resolved
@fdncred

fdncred commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Thanks for all your work here. Is it possible to not have a new crate and put all this in the nu-cmd-base or nu-cmd-extra crate, or even another crate if there's a better fit?

@fmotalleb

Copy link
Copy Markdown
Contributor Author

Yes, that should be fine. I initially kept it as a separate crate because I wanted it to be easy to remove if it turned out not to be a good fit for the shell, and also to keep its dependencies isolated.
Since it originally existed as a plugin crate, I mostly rewrote it as an internal command without changing that structure.

I do not have a strong preference about keeping it separate versus moving it into a other crate. If it makes more sense to place it in nu-command or another appropriate crate, I can do that. In that case, I can also make the JSON formatters pub(crate) again.

@fdncred

fdncred commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

ya, i'd like to see it in another crate. i could live with nu-cmd-base, nu-cmd-extra, or nu-command. Not sure what else fits.

@fmotalleb

Copy link
Copy Markdown
Contributor Author

Moved it to nu-commands/platform to restore format visibility and disabled it for WASM builds. Clipboard behavior still requires manual testing across different platforms and desktop environments.

Tested so far on:

  • Debian (SID) with GNOME on Wayland
  • Windows 11

Based on prior experience, this does not guarantee correct behavior everywhere. Additional testing is needed on:

  • macOS - expected to work
  • Linux systems using X11 - expected to work
  • Simpler or less common desktop environments

We can proceed with this change and address any platform-specific issues as they are discovered.

@github-actions github-actions Bot added A:std-library Defining and improving the standard library written in Nu A:LSP Language Server Protocol (nu-lsp) labels Feb 17, 2026
@fmotalleb
fmotalleb force-pushed the feat/native-clipboard branch from c2a76e3 to 41f2097 Compare February 17, 2026 07:20
@fdncred

fdncred commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

I tested it on:

  • Unbutu 25.04 in WSL
  • Windows 10
  • MacOS 26.3

Seems to work great! It doesn't "just work" in all situations, but I think we can work on those edge cases as we go. What I'm wondering is if it works in all the builds that @hustcer does.

@fmotalleb

Copy link
Copy Markdown
Contributor Author

Also, there is a breaking change "removal of std(-rfc)/clip"
We can delay the release of this PR and add a deprecation message for the std/clip module.

@cptpiepmatz

Copy link
Copy Markdown
Member

Also, there is a breaking change "removal of std(-rfc)/clip" We can delay the release of this PR and add a deprecation message for the std/clip module.

We could just call your commands inside the module, no?

@fmotalleb

Copy link
Copy Markdown
Contributor Author

We can do that, but it raises the question of what problem it actually solves.
If the goal is compatibility, we can instead empty the std/clip module (so codes depending on its existence work) and let it resolve directly to the native clip command, without introducing a wrapper layer around it.
After this change, std/clip would no longer contain any real functionality of its own, which means it is effectively deprecated. Keeping it as a forwarding module would only preserve dead code and add an unnecessary abstraction layer.
In that state, std/clip provides no long-term value and becomes technical debt rather than a compatibility mechanism.

@cptpiepmatz

Copy link
Copy Markdown
Member

I mean with a deprecation message. We don't need this redudancy. You could apply attr deprecated on the module commands to get properl deprecation warnings.

@fmotalleb

Copy link
Copy Markdown
Contributor Author

Understood. In that case, there are two related cleanup points:

  • std-rfc/clip is already deprecated and should be removed.
  • There is also an extra helper called prefix that currently makes std/clip unimportable (actually, its example causes the issue, I can delete the example).
    Should these be removed as part of this change?

Also, the prefix command shouldn't be here; it's not actually related to clip.

@cptpiepmatz

Copy link
Copy Markdown
Member

It seems that clip prefix was already marked for removal, so just removing it should be fine.

@fdncred

fdncred commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

People are going to be mad if clip prefix is gone. The deprecation was to promote it to stdlib vs std-rfc. So, we should keep clip prefix at a mimimum. Also, I wonder if clip paste is still valuable since it uses OSC 52.

@cptpiepmatz

Copy link
Copy Markdown
Member

People are going to be mad if clip prefix is gone.

Oh I thought clip prefix lives somewhere else now. It really has nothing to do with a clipboard imo.

@fmotalleb

Copy link
Copy Markdown
Contributor Author

What to do now XD
I will reset the PR to da3e460 (this PR)
And then do the rest from there

  • Remove std-rfc/clip
  • Mark std/clip's copy and paste deprecated

Then what to do with the prefix?
I think it should be a part of str or std/str or std/utils

@fmotalleb
fmotalleb force-pushed the feat/native-clipboard branch from e495626 to da3e460 Compare February 18, 2026 17:39
@github-actions github-actions Bot removed A:std-library Defining and improving the standard library written in Nu A:LSP Language Server Protocol (nu-lsp) labels Feb 18, 2026
@fdncred

fdncred commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

I'm fine with your changes just to get this PR landed. I'll try to fix the issue in another PR I guess.

@fdncred
fdncred merged commit 2b173be into nushell:main Feb 20, 2026
17 checks passed
@fdncred

fdncred commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Thanks

@github-actions github-actions Bot added this to the v0.111.0 milestone Feb 20, 2026
@fmotalleb
fmotalleb deleted the feat/native-clipboard branch February 20, 2026 14:27
@fdncred fdncred mentioned this pull request Feb 20, 2026
1 task
@ofek

ofek commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

Thanks a lot for supporting this functionality natively! Before releasing, can we please get other people's feedback on the automatic conversion to other types? I use the plugin on which this is based and that behavior is extremely surprising so I always have to pass --raw which is very inconvenient.

edit: on paste not copy

@fdncred

fdncred commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

I like it, it seems very nushell-y to me. Less like posix/bash. Others may feel different.

@ofek

ofek commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Oh, I would very much appreciate an option in the configuration if it's not too much work!

@Tyarel8

Tyarel8 commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Thanks a lot for supporting this functionality natively! Before releasing, can we please get other people's feedback on the automatic conversion to other types? I use the plugin on which this is based and that behavior is extremely surprising so I always have to pass --raw which is very inconvenient.

edit: on paste not copy

There are still some bugs related to this like #16923

@Juhan280

Juhan280 commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

It doesn't compile on android.

This doesn't also seem to use the system-clipboard feature flag.

@cptpiepmatz

Copy link
Copy Markdown
Member

It doesn't compile on android.

This doesn't also seem to use the system-clipboard feature flag.

please move that into a new issue, we can further discuss this there

@fmotalleb fmotalleb mentioned this pull request Feb 21, 2026
1 task
@Bahex

Bahex commented Feb 21, 2026

Copy link
Copy Markdown
Member

I know I'm a bit late to comment on this, but i think clip52 copy/clip52 paste would be much better than clip copy52/clip paste52

@fmotalleb

Copy link
Copy Markdown
Contributor Author

Actually, I wanted to do that, but then I decided not to add more std changes
Changing the namespace would be a more stable approach

@fdncred

fdncred commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

I'm not sure that's a good idea because it now separates the clip commands. You can now no longer find all the clip commands by executing clip. You have to just know the other names or search for them.

astral-l pushed a commit to astral-l/nushell that referenced this pull request Feb 24, 2026
## Release notes summary - What our users need to know
### Cross-platform clipboard command
This PR integrates
[nu_plugin_clipboard](https://github.com/fmotalleb/nu_plugin_clipboard)
into Nushell as a built-in internal command.

Migrating from an external plugin required several changes across the
codebase and internal APIs. Because of this, the current implementation
may not be completely stable and will likely need further testing and
debugging.

This PR prioritizes integration over stability, and additional fixes are
expected in follow-up work.

Examples:
```
# Copy data to the clipboard
~> "data" | clip copy

# Pass through the copied data
~> "data" | clip copy --show | save out.txt

# Retrieve data from the clipboard
~> clip paste
```

Like the original plugin, it can automatically convert objects and
arrays to and from JSON.
This behavior can be disabled using the `--raw` flag on the `paste`
subcommand.
However, to copy a raw value, you must explicitly cast it to a string.

Note: this feature could be removed to keep the command simpler and
aligned with a single-responsibility design, but it's a nice-to-have
thing.

Closes: nushell#16242

## Tasks after merging
- [ ] Update the documentation:
https://github.com/nushell/nushell.github.io
- [ ] Remove the legacy std/clip script

---------

Co-authored-by: Motalleb Fallahnezhad <[email protected]>
@cptpiepmatz cptpiepmatz added notes:additions Noted in "Additions" section and removed notes:mention Noted in "Hall of Fame" section labels Feb 27, 2026
@freijon

freijon commented Mar 3, 2026

Copy link
Copy Markdown

Hi, thank you for your work on this!
I'm packaging nushell for Gentoo Linux and I'm wondering how this new feature relates to the default-disabled system-clipboard feature. Is it required or independent from it? Are there any additional dependencies required?

@cptpiepmatz

cptpiepmatz commented Mar 3, 2026 •

Copy link
Copy Markdown
Member

The nushell cargo feature system-clipboard is independent from these native clip commands. Both use arboard but the cargo feature enables the native clipboard behavior in reedline.

But we moved the native clip commands behind the experimental option native-clip. But that is not a cargo feature.

@SnowSquire

Copy link
Copy Markdown

is there anyway to copy a file, (like the reference/path of a file not the file contents), such that i can paste it into a gui application? i currently achieve this by shelling out to powershell

@Juhan280

Copy link
Copy Markdown
Contributor

Not at the moment.

@fdncred

fdncred commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

is there anyway to copy a file, (like the reference/path of a file not the file contents), such that i can paste it into a gui application? i currently achieve this by shelling out to powershell

You could do something like this.

ls | where type == file | first | get name | path expand | clip copy

Is this what you mean?

@SnowSquire

Copy link
Copy Markdown

is there anyway to copy a file, (like the reference/path of a file not the file contents), such that i can paste it into a gui application? i currently achieve this by shelling out to powershell

You could do something like this.

ls | where type == file | first | get name | path expand | clip copy

Is this what you mean?

it is not, i've posted a comment in the tracking issue for this feature that explains it better. i think thats the correct place #17665

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

Labels

A:LSP Language Server Protocol (nu-lsp) A:std-library Defining and improving the standard library written in Nu new-command notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Concerns About std clip Portability and Inclusion in Standard Library (Again)

9 participants