2012-10-09

Automator script: open chosen/selected folder in iTerm terminal

Here is the AppleScript:
on run {input, parameters}
   tell application "iTerm"
   activate
      repeat with someFilename in input
         make new terminal
         tell the first terminal
            activate current session
            launch session "Default Session"
            tell the last session
               set thePath to (quoted form of POSIX path of ¬
                  (someFilename as string))
               set cdCommand to "if [ -d " & thePath & " ]; then cd " ¬ 
                  & thePath & "; else cd `dirname " & thePath & ¬ 
                  "`; fi; clear"
               write text cdCommand
            end tell
         end tell
      end repeat
   end tell
   return input
end run

Комментариев нет:

Отправить комментарий