Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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've got a shell script file that launches a ruby dev server and sets the title of the window. For some reason it's not working in OS X but it worked in Ubuntu.

Here's my script:

[10:24:48] [user@mac site_web]$ tail ./
title "dev server port 3000"
RAILS_ENV=development rails s -p 3000 --debugger

Runs fine from the command line, but fails from within the script.

[10:18:17] [user@mac site_web]$ title "dev server" 
title changed
[10:18:29] [user@mac site_web]$ ./
./ line 2: title: command not found 

That last line is the issue.

And my title function (in my ~/.bash_profile):

# function for setting terminal titles in OSX
function title {
  printf "\033]0;%s\007" "$1"
  echo "title changed" 

Do I need to do this differently because it's on OSX?

Edit: I tried adding the title function to /Users/[me]/.bashrc and I'm still getting the error.

share|improve this question
Try putting the function in your .bashrc instead – slhck Nov 8 '12 at 18:42
@slhck as i understand it, that doesn't exist on mac os x – jcollum Nov 8 '12 at 18:53
@slhck looks like that was incorrect; added the function to .bashrc and I'm still getting the error – jcollum Nov 8 '12 at 19:16
Well, it doesn't exist per default but it is read by bash when it is invoked. See — in your case though, you should probably source ~/.bash_profile (or ~/.bashrc) from your script. I believe there's something I'm missing here, but sourcing the configuration file should make the function available. – slhck Nov 8 '12 at 19:16
@slhck I tried that just a couple minutes before you commented if [ -f ~/.bashrc] etc.., it didn't change anything – jcollum Nov 8 '12 at 19:19
up vote 1 down vote accepted

I don't have a Mac available to try this, but what if you included a reference to the function source in your script ala:

. $HOME/.bash_profile
title "dev server port 3000"
RAILS_ENV=development rails s -p 3000 --debugger

share|improve this answer
That seems to have fixed it. But I added the title function to my ~/.bashrc and the title function was still not available before I tried your fix. Is there a bashrc file elsewhere in the system on a mac? – jcollum Nov 8 '12 at 19:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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