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 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
1  
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

You must log in to answer this question.

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