Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add clip copy and clip paste #1009

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib-candidate/nupm.nuon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
description: "Official candidates for Nushell standard library"
documentation: "https://github.com/nushell/nu_scripts/blob/main/stdlib-candidate/std-rfc/README.md"
license: "https://github.com/nushell/nu_scripts/blob/main/LICENSE"
version: 0.4.1
version: 0.4.2
type: "module"
}
35 changes: 35 additions & 0 deletions stdlib-candidate/std-rfc/clip/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Commands for interacting with the system clipboard
#
# > These commands require your terminal to support OSC 52
# > Terminal multiplexers such as screen, tmux, zellij etc may interfere with this command

# Copy input to system clipboard
#
# # Example
# ```nushell
# >_ "Hello" | clip copy
# ```
export def copy []: [string -> nothing] {
print -n $'(ansi osc)52;c;($in | encode base64)(ansi st)'
}

# Paste contenst of system clipboard
#
# # Example
# ```nushell
# >_ clip paste
# "Hello"
# ```
export def paste []: [nothing -> string] {
try {
term query $'(ansi osc)52;c;?(ansi st)' -p $'(ansi osc)52;c;' -t (ansi st)
} catch {
error make -u {
msg: "Terminal did not responds to OSC 52 paste request."
help: $"Check if your terminal supports OSC 52."
}
}
| decode
| decode base64
| decode
}
2 changes: 2 additions & 0 deletions stdlib-candidate/std-rfc/mod.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export module aggregate
Copy link
Member

Choose a reason for hiding this comment

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

is this line expected? i don't see any mention to this module anywhere 😮

Copy link
Collaborator

@fdncred fdncred Jan 9, 2025

Choose a reason for hiding this comment

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

It's in the std-rfc stdlib-candidate/std-rfc/aggregate/mod.nu, but I'm not sure it's used in clip/copy/paste.

Copy link
Member

Choose a reason for hiding this comment

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

yeah maybe it's legit overall, just does not look like it belongs here 😉

export module clip
Loading