Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

theosib

macrumors member
Original poster
Aug 30, 2009
71
8
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!
 

chown33

Moderator
Staff member
Aug 9, 2009
10,990
8,874
A sea of green
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.
 
  • Like
Reactions: theosib

theosib

macrumors member
Original poster
Aug 30, 2009
71
8
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?

I'm using Yosemite, so it's in a slightly different place, but your answer lead me to the solution. Thank you!
 

noraa10

Suspended
Jan 11, 2024
2
1
To stop Terminal from showing the current command in the title bar for non-interactive shells on macOS, add the following line to your shell profile configuration file (e.g., ~/.bashrc for Bash or ~/.zshrc for Zsh):

bash

if [ -z "$PS1" ]; then
unset PROMPT_COMMAND
fi

This conditional statement checks if the shell is non-interactive and unsets the PROMPT_COMMAND variable, preventing it from updating the title bar with the current command. Save the file and restart your Terminal or run source ~/.bashrc (or source ~/.zshrc) for the changes to take effect.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.