Previous commands wrapped with square brackets in OS X Terminal

96

19

Yesterday my terminal started surrounding commands that had been run with square brackets. I'm not sure how I've turned this on, but would like to turn it off.

Example: Square brackets around commands

So far, I've done:

  • Checked that there's nothing funny in my .bash_profile
  • Tried changing the profile back to Basic
  • Tried changing to a different shell (zsh)

I've not been able to uncover anything on Google either.

Any ideas?


Update

Output of echo "$PS1"; echo "$PROMPT_COMMAND" enter image description here

Josh

Posted 2015-09-18T09:15:39.277

Reputation: 2 301

? What exactly do you mean? There aren't any [] in your screenshot? – Tonny – 2015-09-18T11:16:04.187

3@Tonny look at the far left and right of the first line - right up against the window edge – Josh – 2015-09-18T11:37:22.583

I see: it's the whole line including the prompt. I was focussing on just the command. I can't recall ever seeing that on my own Mac. I just checked and it isn't present on my 2 Mac's, both run Yosemite, bash with the vanilla config, i never changed that on either machine. – Tonny – 2015-09-18T13:21:33.093

Show us: echo "$PS1"; echo "$PROMPT_COMMAND" – glenn jackman – 2015-09-18T13:43:13.573

I'm guessing that your set-prompt setup commands are slightly messed up. In order to do fancy bold or color formatting, that square-bracket character is used a lot, and I think one of them is showing up in your prompt, instead of formatting the prompt. – jimtut – 2015-09-18T23:23:04.847

1@glennjackman I've updated the question with a screenshot of the output. Googled it, and it looks to be the system defaults. – Josh – 2015-09-19T11:15:32.270

@jimtut Is that related to the $PS1 variable? – Josh – 2015-09-19T11:19:19.870

I use tcsh not the shells you're using, so I can't say for sure. Try tcsh for a minute, see if the bracket disappears. If so, go back to your shell and change $PS1 or whatever variable controls the prompt in your shell. – jimtut – 2015-09-19T15:14:12.917

1

You did not turn it on. The new Marks feature automatically marks prompt lines by default. See here for an explanation about this feature: http://apple.stackexchange.com/questions/209635/

– Chris Page – 2015-11-03T19:40:15.720

Answers

124

Got it! Somehow I'd accidentally turned "Automatically Mark Prompt Lines" on:

enter image description here

I do wonder though where that configuration is stored on disk, as I also tried:

  • Deleting ~/Library/Preferences/com.apple.Terminal.plist
  • Running Terminal from my Yosemite partition (didn't show the marks)
  • Extracting a fresh copy of Terminal from the El Capitan installer (did show the marks)

Josh

Posted 2015-09-18T09:15:39.277

Reputation: 2 301

Deleting the plist may not have been enough. The cfprefsd changes in the last couple of years means that it’s not quite so simple to trash preferences any more. – Zev Eisenberg – 2015-10-02T15:46:21.130

Also: what does “mark prompt lines” mean, and why would you want it? – Zev Eisenberg – 2015-10-02T15:46:54.520

13I think El Capitan turns this on by default I was going crazy until I saw your answer. THANKS! – victmo – 2015-10-03T20:40:23.857

4

See here for an explanation about this feature: http://apple.stackexchange.com/questions/209635/what-functionality-do-marks-offer-in-the-el-capitan-terminal

– nwinkler – 2015-10-09T19:20:12.053

5This was automatically turned on El Capitan for me as well. Amazing how irritating this tiny little graphical anomaly was. Thank you very much for figuring this one out! – Zen – 2015-11-20T01:48:25.303

What is the difference between "Automatically Mark Prompt Lines" and "Hide Marks"? – Nawaz – 2017-04-18T06:58:18.817

27

View > Hide Marks hides these square-bracket lines, without removing the ability to navigate with them, giving the best of both worlds.

Charlie Harding

Posted 2015-09-18T09:15:39.277

Reputation: 766

What is the difference between "Automatically Mark Prompt Lines" and "Hide Marks"? – Nawaz – 2017-04-18T06:58:00.470

1A "mark" on a line is a semantic entity that allows you to navigate back to commands (See Edit > Navigate). Hiding marks removes the visual element, while preserving the location in your terminal. This is the "best of both worlds" because you can still quickly scroll back to your last command, but aren't distracted by the little []s – SubmittedDenied – 2017-08-25T16:01:17.160

6

The preference for turning off prompt marks is:

defaults write com.apple.Terminal AutoMarkPromptLines -int 0

The best write up I have seen on how to use marks is at:

You can also skip one mark if you leave them enabled by pressing Command-Shift-Return to skip marking just this one command line.

bmike

Posted 2015-09-18T09:15:39.277

Reputation: 2 773

1Directly writing the preferences with the implementation-specific key is unnecessary: just use the View > Show/Hide Marks menu item. – Chris Page – 2015-11-03T19:37:48.377

4Of course not @ChrisPage - but it's nice to have the choice for those of us that script our standard setups or desire to change a lab with 100 computers ;-) – bmike – 2015-11-03T19:51:38.710

3In that case I think this answer would be improved if it mentioned that, and first described the menu item. The question is about an individual user interacting with an application, not trying to configure a set of computers. – Chris Page – 2015-11-03T19:57:23.497