How to stop Terminal from showing current command in title bar from non-interactive shell?

Discussion in 'Mac Programming' started by theosib, Aug 24, 2015.

  1. theosib macrumors member

    Joined:
    Aug 30, 2009
    #1
    When I'm running bash scripts and other programs that call the bash shell, the Terminal title bar keep getting updated to display whatever is the currently executing command. The result is that WindowServer uses a ridiculous amount of CPU time.

    How do I stop that from happening?

    I've looked at $PS1 and $PROMPT_COMMAND, but I can't see anything in there that should be changing the window title in a non-interactive shell.

    Thanks!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Which OS version are you using?

    I have 10.8 Mtn Lion on the machine I'm using right now, so the following applies to it. What you see may differ depending on OS version.

    In the 10.8 Terminal, start by looking in:
    Menu: Terminal > Preferences... > Settings pane > Window sub-pane

    Make sure the "Profiles" list on the left shows your current active profile (window display parameters).

    In the Window sub-pane is a heading named "Title" (other headings in this sub-pane: Background, Window Size, Scrollback). "Title" has a text field to enter an arbitrary window title, and a set of checkboxes. One of the checkboxes is "Active process name". Uncheck that.

    Close the window and confirm that this change in settings does what you want, by running a shell script that exhibited the unwanted behavior.

    Does this solve the problem?


    All the settings in the Preferences window are accessible to the 'defaults' command. This means you can control the state of the "Active process name" checkbox using a 'defaults' command-line.

    Is this what you want to do? Or does simply turning off the "Active process name" checkbox accomplish your goal?


    To get a listing of the current Terminal settings, paste this command into Terminal:
    Code:
    cd ~ ; defaults read com.apple.Terminal >what.txt
    Open the file 'what.txt' in TextEdit.app (or a text editor of your choice). Scroll thru and find your active profile, as identified in the "Window Settings" array. Within that profile, find the "ShowActiveProcessInTitle" item, which will be 0 for an unchecked checkbox, or absent or 1 for a checked checkbox. This shows that the setting is obtainable and controllable by the 'defaults' command.

    The 'defaults' command line that changes a specific setting in one of the Window Settings objects is going to be non-trivial. PListBuddy would probably be a better tool, but it's not tied into the defaults/Preferences sub-system.

    You could read the 'defaults' man page and puzzle out the necessary command line, or ask here, after telling us what your chosen window profile name is.
     
  3. theosib thread starter macrumors member

    Joined:
    Aug 30, 2009
    #3
    I'm using Yosemite, so it's in a slightly different place, but your answer lead me to the solution. Thank you!
     

Share This Page