How to open current Terminal directory in the Finder

Terminal users may find it useful to open the current Finder window in the Terminal and open the current Terminal working directory in the Finder. Some options.

If you are a Terminal user and like to explore and manage aspects of OS X using the command line, one convenient function is to be able to quickly access the current folder either in the Finder or in the Terminal. Sometimes navigating through folders can be easier in the Terminal, and at other times it can be easier in the Finder, but the problem comes when you try to combine the use of the two environments in the same task.

Finder to Terminal

">cd to..." in the Toolbar
Placing ">cd to..." in the Finder toolbar will make it easy to access.

Unfortunately the Finder does not have any built-in means to open the current location in the Terminal, but there are a couple of third-party utilities that have this functionality. One I commonly use is a freeware utility called ">cd to..." which will open the foremost Finder window in the Terminal. The utility can be placed in the Dock, but the most convenient location for it is in the Finder toolbar so it can be conveniently accessed from any Finder window.

Terminal to Finder

Though options for opening locations in the Terminal exist, people may not be aware of the option for going in the reverse direction, which is to open the current working directory in the Terminal in a Finder window. This is actually very easy to do, and makes use of OS X's built-in "open" command, which will open a file type or location using the default applications set in the system's Launch Services. When you are in the Terminal, just run the following command:

open `pwd`

In this command, the "grave accent" characters surrounding the "pwd" command (they are not apostrophes) will run the pwd command first so the "open" command can then act on its results. The "pwd" command will output the full path to the "present working directory," and the "open" command will then open this directory in the Finder.

This command is useful especially when you are navigating through hidden directories using the Terminal. Unlike the Finder, which by default hides a number of files based on Finder-specific settings, this command can be used to quickly access these hidden directories. While navigation in this sense is more robust in the Terminal, sometimes using a GUI to manage files is a better option, and this is where this command comes in.

If you find you are using this command frequently, you can save it in a simple shell script and then save the script with a unique name to the /usr/bin/ directory. This will include the command in all other Terminal commands and allow you to quickly access it by just entering the script name at the command prompt.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

Tags:
Computers
About the author

    Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.

     

    Join the discussion

    Conversation powered by Livefyre

    Don't Miss
    Hot Products
    Trending on CNET

    HOT ON CNET

    Looking for an affordable tablet?

    CNET rounds up high-quality tablets that won't break your wallet.