Advertisement
smhdale

NewFinderWindow.scpt

Aug 7th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set targetFolder to path to home folder
  2.  
  3. -- See if active window is a Terminal window
  4. tell application "System Events"
  5.     set frontApp to name of (first application process whose frontmost is true)
  6.     if frontApp is "iTerm2" then
  7.         -- If so, set target folder to the current terminal's `pwd`
  8.         tell application "iTerm"
  9.             tell current session of current window
  10.                 set targetFolder to ((variable named "session.path") as POSIX file)
  11.             end tell
  12.         end tell
  13.     end if
  14. end tell
  15.  
  16. -- Open the new Finder window
  17. tell application "Finder"
  18.     set target of (make new Finder window) to targetFolder
  19. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement