106

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
  • 2,571
  • ? What exactly do you mean? There aren't any [] in your screenshot? – Tonny Sep 18 '15 at 11:16
  • 6
    @Tonny look at the far left and right of the first line - right up against the window edge – Josh Sep 18 '15 at 11:37
  • 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 Sep 18 '15 at 13:21
  • Show us: echo "$PS1"; echo "$PROMPT_COMMAND" – glenn jackman Sep 18 '15 at 13:43
  • 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 Sep 18 '15 at 23:23
  • 1
    @glennjackman I've updated the question with a screenshot of the output. Googled it, and it looks to be the system defaults. – Josh Sep 19 '15 at 11:15
  • @jimtut Is that related to the $PS1 variable? – Josh Sep 19 '15 at 11:19
  • 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 Sep 19 '15 at 15:14
  • 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 Nov 03 '15 at 19:40

3 Answers3

141

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)
royhowie
  • 103
Josh
  • 2,571
  • 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 Oct 02 '15 at 15:46
  • 2
    Also: what does “mark prompt lines” mean, and why would you want it? – Zev Eisenberg Oct 02 '15 at 15:46
  • 13
    I think El Capitan turns this on by default I was going crazy until I saw your answer. THANKS! – victmo Oct 03 '15 at 20:40
  • 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 Oct 09 '15 at 19:20
  • 6
    This 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 Nov 20 '15 at 01:48
  • What is the difference between "Automatically Mark Prompt Lines" and "Hide Marks"? – Sarfaraz Nawaz Apr 18 '17 at 06:58
29

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

  • What is the difference between "Automatically Mark Prompt Lines" and "Hide Marks"? – Sarfaraz Nawaz Apr 18 '17 at 06:58
  • 1
    A "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 Aug 25 '17 at 16:01
7

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
  • 3,061
  • 1
    Directly writing the preferences with the implementation-specific key is unnecessary: just use the View > Show/Hide Marks menu item. – Chris Page Nov 03 '15 at 19:37
  • 5
    Of 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 Nov 03 '15 at 19:51
  • 3
    In 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 Nov 03 '15 at 19:57