Skip to content

Instantly share code, notes, and snippets.

@rcanand
Last active February 11, 2025 17:13
Show Gist options
  • Save rcanand/0471ea93c05e531e699517331d55b2f1 to your computer and use it in GitHub Desktop.
Save rcanand/0471ea93c05e531e699517331d55b2f1 to your computer and use it in GitHub Desktop.
Cursor clear terminal with keyboard shortcut

Cursor clear terminal with keyboard shortcut

Problem

Cursor hijacks Cmd-K, Cmd-Shift-K, Cmd-L for launching AI. Some of these are used to clear the terminal. You can type clear in the terminal, but that does not work if you have already typed in a command, and want to clear before it is run.

Workaround

This is a workaround with a custom keyboard shortcut (I use Cmd-Alt-K, on mac, you can change to anything you want that doesn't conflict with your existing workflows).

Note: you must be in the terminal to run this shortcut - you can switch to terminal using Ctrl+backtick (Yes, Ctrl, not Cmd on mac as well).

This tip is from cursor chat > claude 3.5 sonnet (updated for formatting and removed some platitudes)

  1. Use VS Code’s Keybindings: Visual Studio Code lets you map custom key combinations to built-in commands. In this case, you can bind Cmd+Alt+K to a command that clears the terminal.

  2. Select the Appropriate Command: VS Code already provides a built-in command for clearing the integrated terminal: "workbench.action.terminal.clear" This command immediately clears the terminal’s output (it does not send the text "clear" into the terminal, but it effectively clears it).

  3. Modify Your Keybindings File: Open your keybindings JSON file (via the command palette, search for “Preferences: Open Keyboard Shortcuts (JSON)”) and add an entry mapping the key combination to the command. For example, you might add an entry similar to:

{
  "key": "cmd+alt+k",
  "command": "workbench.action.terminal.clear",
  "when": "terminalFocus"
}

This ensures that the shortcut takes effect when the terminal is active (the "when" clause is optional but recommended to avoid unintended conflicts).

Verify Conflict-Free Assignment: Make sure no other command is bound to Cmd+Alt+K. If there is, you may need to remove or change the conflicting binding.

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