Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 27th, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. AppleScript: how to get the current directory of the topmost Terminal
  2. tell application "Terminal"
  3.     do shell script "fuser " & (tty of front tab of front window)
  4. end tell
  5.        
  6. #!/bin/bash
  7.  
  8. function pwdx {
  9.     lsof -a -p $1 -d cwd -n | tail -1 | awk '{print $NF}'
  10. }
  11.  
  12. for pid in $(osascript "$(dirname "$0")/get_foregroundterminal_proclist.scpt"); do
  13.     pwdx $pid
  14.     break # break on first
  15. done