Ok, I have one solution.

get_foregroundterminal_proclist.scpt:

tell application "Terminal"
    do shell script "fuser " &amp; (tty of front tab of front window)
end tell


get_foregroundterminal_curdir.sh:

#!/bin/bash

function pwdx {
    lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $NF}'
}

for pid in $(osascript "$(dirname "$0")/get_foregroundterminal_proclist.scpt"); do
    pwdx $pid
    break # break on first
done


AppleScript: how to get the current directory of the topmost Terminal
I have a question that sounds simple but it's driving me mad for some days. I have a historical time series closed in two lists: the first list is containing prices, let's say P = [1, 1.5, 1.3 ...] while the second list is containing the related dates, let's say D = [01/01/2010, 02/01/2010...]. What I would like to do is to plot SOME of these dates (when I say "some" is because the "best" result I got so far is to show all of them as tickers, so creating a black cloud of unreadable data in the x-axis) that, when you zoom in, are shown more in details. This picture is now having the progressive automated range made by Matplotlib: 



Instead of 0, 200, 400 etc. I would like to have the dates values that are related to the data-point plotted. Moreover, when I zoom-in I get the following: 



As well as I get the detail between 0 and 200 (20, 40 etc.) I would like to get the dates attached to the list. 
I'm sure this is a simple problem to solve but I'm new to Matplotlib as well as to Python and any hint would be appreciated. Thanks in advance
