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 have seen many questions about how to set the tab (or window) name, but how to get it? I have setup terminal to open 8 tabs, each tab having its own name (dev1, dev2, ... dev8) Is there any way for a shell script to identify in which tab it is (read the tab's name?)

share|improve this question
Similar question on stackoverflow – glenn jackman Jun 17 '13 at 18:13

This works on my Fedora box, but I don't have a Mac to verify:

xprop -id $WINDOWID | grep '^WM_NAME(STRING)' | cut -d\" -f2
share|improve this answer
My OS X 10.8 does not come with xprop installed. – Arjan Jun 17 '13 at 18:31

If all else fails, then AppleScript to the rescue:

title=`osascript -e 'tell application "Terminal" to  get name of front window'`
echo $title

Beware though when using of front window when using multiple windows. This will print the wrong results when switching to another tab in 5 seconds:

sleep 5; osascript -e 'tell application "Terminal" to  get name of front window'

(So I hope someone can give you an easier way.)

share|improve this answer

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.