How do I make a custom context menu item in Finder?

Solution 1:

If you want the cd command in a new window or tab, you can simply turn on the built-in services, "New Terminal at Folder" and "New Terminal Tab at Folder", by going to System Preferences > Keyboard > Keyboard Shortcuts > Services > Files and Folders.

If you want the cd command in the active window or tab, you can make a simple Automator Service.

  1. In a new Automator Service, change "Service receives selected" to folders.
  2. Add a "Run AppleScript" action.
  3. Replace (* Your script goes here *) with the following:

    tell application "Terminal"
        reopen
        activate
        set cmd to "cd " & quoted form of posix path of input
        try
            if busy of selected tab of window 1 then error
            do script with command cmd in window 1
        on error
            do script with command cmd
        end try
    end tell
    
  4. Save the service with whatever name you want your menu item to have, then it's ready to go.

An alternative to using a contextual menu is to just type cd (with a trailing space) then drag the folder to the Terminal window.