Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to setup visual alerts when working within certain directories within mac osx terminal.

Specifically, I have several projects running within the same framework which can easily lead to mistakes. I end up running a pwd before other commands if I've been away for the terminal windows for more than a few moments. Seems like a dumb extra step.

All resources I've found are just about setting up color profiles in my bash profile :(

UPDATED Here is the answer so far (does bark a note, doesn't work for color). Read below for why.

#! /bin/bash -i

# Add this to ~/.bash_profile
# PROMPT_COMMAND=/usr/local/bin/coloraware


case "$PWD/" in
        export PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '
        echo "Project #1"
        export PS1='\[\e[1;34m\][\u@\h \W]\$\[\e[0m\] '
        echo "Project #2"
        export PS1='\[\e[1;35m\][\u@\h \W]\$\[\e[0m\] '
        echo "Project #3"
share|improve this question
possible duplicate of OS X Terminal command to change color themes – slhck Apr 18 '12 at 6:57
This is what I was referring to above as NOT the issue. All resources out there are just how-to-set-colors-all-the-time guides. – doublejosh Apr 24 '12 at 21:40

You can change the color of your terminal session as explained in @DanielBeck's answer here.

You could wrap the call to osascript in a shell script that pulls your current working directory, then put that shell script somewhere into your $PATH, or possibly even into your command prompt PS1.

For example, if the basename of the working directory is my home folder, then run the AppleScript command to change colors (or, in this case, just nag me with a dialog).

if [ $(basename $PWD) = "werner" ]; then
  osascript -e 'tell app "Finder" to display dialog "foo"'
share|improve this answer
Thanks for the color link and getting me on target with comparisons. Don't understand how this gets called automatically while in a folder to do the chirping or coloring. (Tried placing a direct link to the script into my $PATH in .bash_profile) – doublejosh Apr 24 '12 at 21:37
Found the answer here:… – doublejosh Apr 24 '12 at 21:48
@doublejosh Ah, fair enough — maybe just post your answer here and mark it as accepted yourself :) – slhck Apr 24 '12 at 21:51
Still dealing within settings the PS1 within a script. Added #! /bin/bash -i to my header, but can't seem to set the color within the script. Will post the final result for sure! – doublejosh Apr 24 '12 at 22:09
These folks seem to be doing so in a script, but I just can't get it to stick.… Assume it's because the script swapped the color and parent shell stayed the same. Seems like the answer might be in here:… or here with --rcfile – doublejosh Apr 25 '12 at 1:14

You must log in to answer this question.

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