81

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

  • ? What exactly do you mean? There aren't any [] in your screenshot? – Tonny Sep 18 '15 at 11:16
  • 2
    @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
111

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)
  • 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 2 '15 at 15:46
  • Also: what does “mark prompt lines” mean, and why would you want it? – Zev Eisenberg Oct 2 '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 3 '15 at 20:40
  • 4
    See here for an explanation about this feature: apple.stackexchange.com/questions/209635/… – nwinkler Oct 9 '15 at 19:20
  • 5
    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 1:48
24

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"? – Nawaz Apr 18 '17 at 6: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
5

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.

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.