Skip to content

Commit 77b60a1

Browse files
committed
docs: Add VS Code how-to guide for fixing Ctrl+C in terminal
1 parent 2644b88 commit 77b60a1

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
tags:: [[VSCode]], [[Terminal]], [[Diataxis/How To]]
2+
3+
- # How To Fix Ctrl+C Not Working in VS Code Integrated Terminal
4+
- ## Overview
5+
- This guide helps you fix issues where Ctrl+C (SIGINT) doesn't work to interrupt processes running in VS Code's integrated terminal
6+
- Useful when running long-lived processes like `caffeinate` or other commands that should be interruptible
7+
- Addresses VS Code terminal keybinding interception and signal handling issues
8+
- ## Prerequisites
9+
- VS Code installed and running
10+
- Access to VS Code settings
11+
- A command or process that needs to be interruptible with Ctrl+C
12+
- ## Steps
13+
- ### 1. Enable sendKeybindingsToShell Setting
14+
- Open VS Code Settings (Cmd+, on macOS or Ctrl+, on Windows/Linux)
15+
- Search for `terminal.integrated.sendKeybindingsToShell`
16+
- Check the box or set the value to `true`
17+
- This allows terminal keybindings to pass through to the shell instead of being intercepted by VS Code
18+
- ### 2. Configure commandsToSkipShell (Alternative Method)
19+
- Open VS Code Settings
20+
- Search for `terminal.integrated.commandsToSkipShell`
21+
- Click "Edit in settings.json"
22+
- Remove `workbench.action.terminal.sendSequence` from the array if present
23+
- Or ensure Ctrl+C keybindings are not blocked by other commands in this list
24+
- ### 3. Verify the Fix
25+
- Open a new integrated terminal in VS Code
26+
- Run a test command like `caffeinate -d -i -m -s` or `sleep 30`
27+
- Press Ctrl+C
28+
- The command should interrupt successfully
29+
- ### 4. Alternative: Use External Terminal (If Issue Persists)
30+
- If the integrated terminal still has issues, run long-lived processes in your system's native terminal application
31+
- On macOS: Open Terminal.app
32+
- On Windows: Open PowerShell or Command Prompt
33+
- On Linux: Open your default terminal emulator
34+
- Run your command there where Ctrl+C works reliably
35+
- ### 5. Alternative: Background Process and Kill by PID
36+
- If you must use VS Code terminal and Ctrl+C doesn't work:
37+
- Run your command in the background by appending `&`:
38+
~~~bash
39+
caffeinate -d -i -m -s &
40+
~~~
41+
- Note the process ID (PID) that appears
42+
- When you need to stop it, run:
43+
~~~bash
44+
kill <PID>
45+
~~~
46+
- Or use `pkill` to find and kill by process name:
47+
~~~bash
48+
pkill -f caffeinate
49+
~~~
50+
- ## Troubleshooting
51+
- If Ctrl+C still doesn't work after enabling `sendKeybindingsToShell`:
52+
- Restart VS Code to ensure settings take effect
53+
- Check if you have VS Code extensions that might intercept terminal input
54+
- Verify your shell profile (`.zshrc`, `.bashrc`) doesn't override signal handling
55+
- If the setting doesn't appear in Settings UI:
56+
- Open `settings.json` directly (Cmd+Shift+P → "Preferences: Open User Settings (JSON)")
57+
- Add manually: `"terminal.integrated.sendKeybindingsToShell": true`
58+
- For commands that specifically ignore SIGINT:
59+
- Some processes like `caffeinate` may need SIGTERM instead:
60+
~~~bash
61+
kill -TERM <PID>
62+
~~~
63+
- Or force kill with SIGKILL (use as last resort):
64+
~~~bash
65+
kill -9 <PID>
66+
~~~
67+
- ## Related
68+
- [VS Code Terminal Advanced Documentation](https://code.visualstudio.com/docs/terminal/advanced)
69+

0 commit comments

Comments
 (0)