Why is there a left bracket before my bash prompt?

I've notice that after I execute commands, a left bracket character will appear before the previous line. It seems to be partially dependent on what's in $PS1. I've tried unsetting $PROMPT_COMMAND and $PS1 but that did not make a difference. Here is an example of this happening in Terminal.app:

Terminal.app


Solution 1:

I figured it out. I went to View->Hide Marks and the [ characters disappeared.

Solution 2:

The new Marks feature in El Capitan 10.11 Terminal adds structure to the terminal contents by marking prompt lines and other interesting content, enabling operations like navigating, selecting, Copying, Printing and deleting commands or their output.

See the Edit menu, especially the Marks, Bookmarks, and Navigation submenus for Marks-related commands.

Marks are indicated with “square brackets” at either end of a marked line. Bookmarks are a more heavyweight mark—they're used for marking sections with a time stamp or a custom name—and are indicated with thicker vertical lines and a different background color.

You can hide the mark indicators if you don't want to see them, with the View > Hide/Show Marks menu item. This doesn't remove marks or prevent the Marks-related commands from working.

A good explanation of what you can do with Marks and the related commands is found in @nwinkler's answer to this question.