I see “awk”, “find”, “sed”, and “which” momentarily appear in my Terminal window's title when changing directories.  (And not all of these always appear and there could be some I'm missing; I imagine this is because the title changes multiple times before the UI redraws.)

Although this is likely just some shell scripts and additions I've installed along the way (git status in PS1, perhaps), I'd like to investigate it just to make sure.  Is there an easy way to find out what script(s) are calling these?

Note on Context: I'm looking for a general investigative approach to discovering what is calling the sub-commands. My programmer's mindset makes me want a solution that would temporarily replace the sub-command with a stubbed one (à la #define/#undef) that would dump a stack trace at the point of call, then either call the original command or just abort. This approach may or may not be applicable to the shell.

Also: I'm primarily on OS X 10.8 using GNU bash 3.2.48.  I'm not sure if the system and bash version is completely relevant to the problem at-hand— a solution that works on my Debian instance as well would be nice.

2 Answers 2


With bash you can use set -o verbose:

$ set -o verbose
$ cd ~/Documents
cd ~/Documents

bash -lv would start a new login shell with the same option enabled.

For example update_terminal_cwd is defined in /etc/bashrc, which isn't indexed by Spotlight. But you can see the definition with declare -f update_terminal_cwd or set.

sudo opensnoop -n bash shows what files are accessed by processes named bash.


Your problem is not with the command itself. The problem is with the git status in PS1. Simply, every time you supply a command, PS1 becomes evaluated. In order for git status to appear, there is a batch of command executed in the current working directory. For example, it checks if the current directory is a git repo or not, then checks the branch name, may be some commit number or what status you decided to keep.

I am not quite sure if the solution suggested by Lauri will show such evaluations or not, but you may give it a shot.

  • 1
    The git-status-in-PS1 thing was just a guess, because I know I have that set up. While I know there probably are other things altering my PS1 (on my system), is PS1 the only thing that gets evaluated when changing directories? Or are there other hooks I should investigate? Apr 19, 2013 at 2:19
  • I will of course try disabling my PS1 settings and see if that solves my specific issue. However, the general problem still stands. Apr 19, 2013 at 2:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .