Terminal bracketed paste mode

Terminal bracketed paste mode

If you got some special characters when you paste a string into terminal, if they are at beginning or end of the string, then this could be bracketed paste mode caused issue.

Bracketed paste

The bracketed paste mode is to tell terminal that those strings are not typed in, they are pasted in. This can help software implemented action correctly, for example, auto indent mode should be disabled when pasting multiple lines into editor, such as vim.

In bracketed mode

If in bracketed mode, the ^[[200~ is added at beginning of string, the ^[[201~ is appended at end of string. For example, if paste string some test, terminal's app receives following string.

^[[200~some test^[[201~

Enable bracketed mode

To enable bracketed mode, run following command

printf "\e[?2004h"

Disable bracketed mode

To disable bracketed mode, run following command

printf "\e[?2004l"


Bracketed Paste Mode in Terminal

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

The reCAPTCHA verification period has expired. Please reload the page.