LoginSignup
1
2

More than 5 years have passed since last update.

Open a directory in iTerm from a context menu

Posted at
on run {input, parameters}
    tell application "Finder"
        set dir_path to "\"" & (POSIX path of (input as string)) & "\""
            -- display dialog dir_path
    end tell
    CD_to(dir_path)
end run

on CD_to(theDir)
    tell application "iTerm"
        activate
        try
            set t to the last terminal
        on error
            set t to (make new terminal)
        end try
        tell t
            launch session "Default Session"
            tell the last session
                write text "cd " & theDir & ";clear;"
            end tell
        end tell
    end tell
end CD_to
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2