How to fix your terminal prepending 00~ when pasting in anything
Turning off Paste Bracketing in iTerm2.
If pasting in iTerm2 or similar terminal emulator prints 00~
before your text, your terminal is leaking bracketed-paste markers because the shell can’t handle them. This typically happens on iTerm2 if an SSH session ended weirdly or your editor crashed or if your Bash is very old. See iTerm2’s help article about paste bracketing.
My terminal was wrapping a paste with ESC [ 200 ~
… ESC [ 201 ~
, but my old macOS Bash (3.2 with old Readline) didn’t recognize that, so part of the marker showed up as literal 00~
. The fix: using a shell/readline that supports bracketed paste, or disable the feature in the terminal emulator.
Symptom
- Pasting at a plain Bash prompt prints
00~
before the pasted text. - You can check this by doing:
cat -v
Paste anything. If you see ^[[200~ ... ^[[201~
, bracketed paste is active. Ctrl+C
to exit.
Cause
- iTerm2 only sends those markers when an app or shell enables bracketed paste.
- Bash <= 3.2 doesn’t parse them so some of the sequence (often
00~
) prints. - It can appear “random” because a tab can be left in that mode after a program exits or a session dies; new tabs are clean.
Fixes
1) Just upgrade Bash
Using brew
and on macOS:
brew install bash
echo "/opt/homebrew/bin/bash" | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/bash
Open a new terminal window.
Verify:
echo $SHELL # /opt/homebrew/bin/bash
bash --version # 5.x
Note: Intel Macs may use
/usr/local/bin/bash
instead of/opt/homebrew/bin/bash
.
2) Turn it off in iTerm2
iTerm2 might even prompt you:
You can change preferences for iTerm2: Preferences → Advanced → search “bracketed” → tweak paste bracketing.
Verify it’s gone
cat -v
Paste again. You should not see ^[[200~ ... ^[[201~
.