warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
20.97k stars 359 forks source link

Custom Keyboard Shortcut for "Copy" does not copy selected command text, only command output #3558

Open MikeChristensen opened 1 year ago

MikeChristensen commented 1 year ago

Discord username (optional)

No response

Describe the bug

I would like to override the Cmd+C default Mac "Copy" command with the Windows/Linux version, Ctrl+C, mainly because that's what I'm used to. Right now, there doesn't appear to be a way to do that.

To reproduce

In Settings->Keyboard Shortcuts, define the Copy command as such:

image

Note, for some reason if you define a shortcut for Copy, it sets the same shortcut to Copy Command and Output. This might be related to this issue. Because of this, it appears they conflict in the UI but I'm not sure if it matters.

Next, go type in a command and select part of it:

image

Then, press Ctrl+C to copy the text.

Result:

The selected text is NOT copied to the clipboard. Using the OS default Cmd+C will work still.

Note, the context menu will even show the keyboard binding is supposed to work:

image

Also note the keyboard binding will work to copy the actual output of a command:

image

Expected behavior

If I use Ctrl+C as a custom keyboard shortcut for Copy, I should be able to use that shortcut to copy selected text within the command input.

Screenshots

No response

Operating system

MacOS

Operating system and version

13.4.1

Shell Version

zsh 5.9 (x86_64-apple-darwin22.0)

Current Warp version

v0.2023.08.15.08.03.stable_00

Regression

No, this bug or issue has existed throughout my experience using Warp

Recent working Warp date

No response

Additional context

No response

Does this block you from using Warp daily?

No

Is this a Warp specific issue? (i.e. does it happen in Terminal, iTerm, Kitty, etc.)

N/A, the issue only applies to a Warp specific feature. (i.e. Warp AI, Workflows)

Warp Internal (ignore): linear-label:b8107fdf-ba31-488d-b103-d271c89cac3e

None

warpdotdev-devx[bot] commented 1 year ago

Hi @MikeChristensen Coming from Windows, I can empathize with this CTRL v CMD muscle memory.

Since copy/paste is also a systemwide shortcut, the easiest way to accomplish what you need without having to rebind every shortcut in apps like Warp(or others that expect this default) is to swap the modifier keys in the Mac > System Settings > Keyboard > Keyboard Shortcuts > Modifier Keys.

https://github.com/warpdotdev/Warp/assets/16809145/9d7861e9-2ec4-4a31-8545-502dcac5861a

If you'd like to go the harder route, you can change the shortcuts for Copy in Mac settings to CTRL-C, and then rebind all the appropriate shortcuts in Warp to CTRL-C. Also, CTRL-C is the default for "Clear Command Editor" in Warp, so you will also want to clear that key bind as well for this to work.

Let me know if this helps.

MikeChristensen commented 1 year ago

Let me know if this helps.

Yea, I've tried swapping CTRL and CMD at the OS level before, and it always causes weird problems. I've found it better to just rebind specific keys in specific apps.

I wish Mac just adopted the Ctrl key standard, like everything else in the world.

MikeChristensen commented 1 year ago

Another annoying behavior in Warp.

If you bind the Ctrl+C keyboard shortcut to Copy, it will break other programs that use Ctrl+C to terminate, such as ssh or what not.

The ideal behavior for Warp would be to only Copy if there's text selected. Otherwise, it should just send ^C to the running program.

dannyneira commented 10 months ago

Heard, you may be able to just enable Copy on Select as a workaround and not have to use shortcuts.

dannyneira commented 9 months ago

@MikeChristensen, I found a workaround you can try, clear the keybindings for "Copy" as well as "Copy Command and Output", then set the keybind for "Copy" to CTRL-C. Since Copy either copies the entire block, or selected text, the keybind for normal "Copy" will duplicate the same keybind for "Copy Command and Output", but it should work without overriding the Mac settings.

https://github.com/warpdotdev/Warp/assets/16809145/d2116306-e637-46e7-b460-b989121d0feb

Let me know if that helps with your issue.

MikeChristensen commented 9 months ago

@dannyneira Yea, I actually gave up on this since overriding ^C breaks the ability to terminate running processes which I do a lot. The behavior I would like is CTRL+C would only do anything if there's an active selection in the terminal, otherwise a SIGTERM should be sent to the process. This is how the Windows Terminal behaves. However, I guess that's a lot to ask.

I've actually gone down the Karibiner path to get the OS working a lot more like Windows. This took a ton of work and involves things like app-specific keyboard bindings, but I have it very close now without having to override individual keyboard bindings in applications such as Warp or VSCode.

dannyneira commented 9 months ago

Thanks for the update. When we release windows version of Warp this functionality you request may be possible, although I'm not sure it will be ported to Mac so it seems like the karibiner route you went is most likely the best workaround for now. I'll close this as resolved since you have the functionality you want, if you'd like something more like windows terminal, please open a feature request for that.