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

Use the system clipboard only for explicit copy/paste operations. Addresses issue 11907 #12179

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -158,7 +158,7 @@ wasi = ["nu-cmd-lang/wasi"]
static-link-openssl = ["dep:openssl", "nu-cmd-lang/static-link-openssl"]

mimalloc = ["nu-cmd-lang/mimalloc", "dep:mimalloc"]
system-clipboard = ["reedline/system_clipboard"]
system-clipboard = ["reedline/system_clipboard", "nu-cli/system-clipboard"]

# Stable (Default)
which-support = ["nu-command/which-support", "nu-cmd-lang/which-support"]
Expand Down
1 change: 1 addition & 0 deletions crates/nu-cli/Cargo.toml
Expand Up @@ -45,3 +45,4 @@ which = { workspace = true }

[features]
plugin = []
system-clipboard = ["reedline/system_clipboard"]
7 changes: 7 additions & 0 deletions crates/nu-cli/src/reedline_config.rs
Expand Up @@ -1284,7 +1284,14 @@ fn edit_from_record(
}
"complete" => EditCommand::Complete,
"cutselection" => EditCommand::CutSelection,
#[cfg(feature = "system-clipboard")]
"cutselectionsystem" => EditCommand::CutSelectionSystem,
"copyselection" => EditCommand::CopySelection,
#[cfg(feature = "system-clipboard")]
"copyselectionsystem" => EditCommand::CopySelectionSystem,
"paste" => EditCommand::Paste,
#[cfg(feature = "system-clipboard")]
"pastesystem" => EditCommand::PasteSystem,
"selectall" => EditCommand::SelectAll,
e => {
return Err(ShellError::UnsupportedConfigValue {
Expand Down
15 changes: 9 additions & 6 deletions crates/nu-utils/src/sample_config/default_config.nu
Expand Up @@ -824,19 +824,22 @@ $env.config = {
mode: emacs
event: { edit: capitalizechar }
}
# The *_system keybindings require terminal support to pass these
# keybindings through to nushell and nushell compiled with the
# `system-clipboard` feature
{
name: copy_selection
name: copy_selection_system
Copy link
Member

Choose a reason for hiding this comment

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

May be worth adding a comment that this requires the terminal to support the ctrl-shift bindings passing through (and the system-clipboard feature, if it is likely to be disabled on a build).

modifier: control_shift
keycode: char_c
mode: emacs
event: { edit: copyselection }
event: { edit: copyselectionsystem }
}
{
name: cut_selection
name: cut_selection_system
modifier: control_shift
keycode: char_x
mode: emacs
event: { edit: cutselection }
event: { edit: cutselectionsystem }
}
{
name: select_all
Expand All @@ -846,11 +849,11 @@ $env.config = {
event: { edit: selectall }
}
{
name: paste
name: paste_system
modifier: control_shift
keycode: char_v
mode: emacs
event: { edit: pastecutbufferbefore }
event: { edit: pastesystem }
}
]
}