Open folder with terminal mac os

How to Open Any Folder from the Mac Terminal

The standard way to open any directory within macOS is to open a Finder window and use it to navigate to a specific location on your hard drive. There’s also another way to open folders: use the Terminal. It may not be something you use every day unless you’re a developer, but the power is there if you need to call on it.

As such, this post will show you how to open any folder from the macOS Terminal. We also show you how to create a custom shortcut to carry out this command.

Also read: How to Customize Your Mac’s Terminal for Better Productivity

Why You’d Want to Open a Folder From the Mac Terminal

As we noted, the preferred way of opening a folder is by using Finder. This is a Graphical User Interface (GUI), and it’s macOS’s directory navigation de jure. But it’s not the only way to access files or folders within macOS.

We admit, using the Terminal to open folders isn’t a natural way to get around macOS. Though, you’ll find it will come in handy in the following situations:

  • If you’re a command line user, it may be something you have in your toolbox.
  • Developing for Mac often means working within the Terminal. If this is the case, it may be the path of least resistance to stay inside the Terminal as much as possible.
  • If you’re in a rare situation where macOS is acting as server software, you may only be able to use the Terminal to navigate the Operating System (OS).

Given the above, it’s easy to see why you may want to have the knowledge. Next, we show you how to get the job done.

How to Open Any Folder from the Mac Terminal

To begin, you’ll need to open the Terminal. This can be found either through the “Application -> Utilities” folder

or by typing “Terminal” in Spotlight. Once it’s open, you won’t need any dependencies to open any folder from the Mac Terminal. You’ll only need the open command. The general syntax is as follows:

For example, to open the Pictures folder, you’d use the following:

This will open the Pictures folder in a Finder window, which you can then use to access its files.

There are a bunch of other short commands you can use to access specific folders. For example:

  • To open the Root directory, use open / .
  • For your Home folder (i.e. the folder containing Desktop, Documents, and other folders specific to the user), type open

.

  • To open the current working folder within Finder, use open . .
  • To touch on this last point further, you may be navigating your files using the Terminal and have a need to open the folder you’re in.

    While the commands so far open specific folders, you can also launch (and update) applications from the Terminal without using Finder. For example, to open Safari, type open /Applications/Safari.app .

    Of course, you’re able to replace Safari with any app on your system as long as you know its file name.

    Open a Folder in Terminal from a Shortcut Menu

    It may be that you want to reverse the situation and open a Finder directory in the Terminal. In other words, make it the current working directory. You can do this by adding a right-click shortcut.

    To do this, head to System “Preferences -> Keyboard.”

    Next, navigate to the Shortcuts tab. Here, select the Services menu and scroll down to find “New Terminal at Folder.”

    If you select any folder within Finder, open the Services menu from the Toolbar and choose “New Terminal at Folder.”

    This is going to be ideal if you often switch between a GUI and the Terminal.

    In Summary

    The Mac Terminal isn’t something you’ll encounter often. In contrast, a developer or sysadmin might spend most of their time using a Terminal app. Given this, opening a folder is a basic task that can keep you on the command line as long as possible. All you need is the open command and the path to your folder.

    If you’re looking for more to do with the Terminal, we’ve looked at searching the Web without a browser, direct from the command line. Will this inspire you to use the Mac Terminal more? Share your thoughts in the comments section below!

    Tom Rankin is a quality content writer for WordPress, tech, and small businesses. When he’s not putting fingers to keyboard, he can be found taking photographs, writing music, playing computer games, and talking in the third-person.

    Источник

    Open Current Folder in Finder from Terminal of Mac OS X

    Want to open a Finder window from the current directory location in Terminal? Mac OS makes this easy!

    From the Mac Terminal, you can immediately open whatever folder or directory you are working within into the Finder of MacOS and Mac OS X by simply typing the a short command string and executing it. To try this out yourself, you’ll want to use the following command:

    How to Open the Current Directory in a Finder Window from Terminal on a Mac

    Assuming you’re already in the Terminal application, found in /Applications/Utilities/ the command to type is as follows:

    Hitting return and executing “open .” (yes that is a period, and yes it is required) will open the present working directory (PWD in the world of UNIX acronyms) in the Terminal / Command line into the Finder of the Mac – you know, the visual file system.

    You can do this from anywhere in the command line as long as you’re in a local path, but it doesn’t matter if it’s system files or user files, you can launch it into the Finder. This can actually be a really helpful way to modify and adjust buried system files if you found them through the command line but now need to interact with them in the Finder.

    For example if you’re digging around in /Library/Preferences/Mozilla/ and type open . that folder will be opened in the Finder. Or if your CWD is /etc/ and you want to access that directory immediately in Finder, type ‘open .’ to access it.

    The screenshot above shows this in action while the PWD within the Terminal is the /Applications directory, thus the Applications folder is opened in the Finder.

    This is useful for many reasons that I’m sure you can think of, and it’s one of those must-know tricks for command line users in Mac OS X.

    By the way, you can also set this up to go the other way, from Finder to Terminal, if you’d like.

    This isn’t the only option to open the present working directory from Terminal into a new Finder window on the Mac, you can also use the ‘open’ command like so:

    Note that those are not quotation marks but the tilde press instead. As mentioned before, pwd stands for present working directory, and this launches into that in a new Finder window the same way ‘open .’ does.

    Use whichever approach works for your needs. And if you have any similar tips or tricks for opening Finder windows from the command line of Mac OS, share them in the comments below!

    Источник

    Open terminal here in Mac OS finder [closed]

    Is there something similar to the «Open Command Window Here» Windows Powertoy for Mac OS? I’ve found a couple plugins through a google search but wanted to see what works best for developers out there.

    14 Answers 14

    As of Mac OS X Lion 10.7, Terminal includes exactly this functionality as a Service. As with most Services, these are disabled by default, so you’ll need to enable this to make it appear in the Services menu.

    System Preferences > Keyboard > Shortcuts > Services

    Enable New Terminal at Folder. There’s also New Terminal Tab at Folder, which will create a tab in the frontmost Terminal window (if any, else it will create a new window). These Services work in all applications, not just Finder, and they operate on folders as well as absolute pathnames selected in text.

    You can even assign command keys to them.

    Services appear in the Services submenu of each application menu, and within the contextual menu (Control-Click or Right-Click on a folder or pathname).

    The New Terminal at Folder service will become active when you select a folder in Finder. You cannot simply have the folder open and run the service «in place». Go back to the parent folder, select the relevant folder, then activate the service via the Services menu or context menu.

    In addition, Lion Terminal will open a new terminal window if you drag a folder (or pathname) onto the Terminal application icon, and you can also drag to the tab bar of an existing window to create a new tab.

    Finally, if you drag a folder or pathname onto a tab (in the tab bar) and the foreground process is the shell, it will automatically execute a «cd» command. (Dragging into the terminal view within the tab merely inserts the pathname on its own, as in older versions of Terminal.)

    You can also do this from the command line or a shell script:

    This is the command-line equivalent of dragging a folder/pathname onto the Terminal application icon.

    Источник

    Access Applications directory in Terminal

    I’m really new to command line and I’m trying to access my Applications directory within Terminal.

    By default, I am stuck in my user directory but Applications is a child of the «Macintosh HD».

    Any tips on how to get to this directory as opposed to username>Applications?

    4 Answers 4

    In the Terminal you can type the absolute path.

    to access applications installed for all users.

    If you want to access the root folder (named «Macintosh HD», in your case), it called / in Mac OS X (and other UNIX variants).

    And cd , meaning change directory, is used to navigate.

    Alternatively, you can use the shortcut ⌘ + ⇧ + G in the Finder and type.

    You do not need to type out the whole name. Tab-completion automatically adds the last letters. You can invoke tab-completion by pressing ⇥ while typing /Applications .

    In terminal type:

    Or you can just type:

    At this point, if you type pwd (print working directory) it should return /Applications

    A great place to start with Terminal is http://linuxcommand.org/learning_the_shell.php even though it is aimed at Linux users

    To navigate using the terminal you will use 2 commands; cd and ls .

    To change directory you use cd . Ex: cd myfolder/anotherFolder .

    You can type pwd to display the current directory you are in.

    To list the content of a directory use ls . You can get more info about the content of a directory using ls -al .

    You will notice that here are 2 directories which are always present wherever you list the content of a directory: . and .. .

    . is simply a reference to the current directory so typing cd ./somedir and cd somedir are equivalent.

    .. is a reference to the parent directory. So using cd .. will move you back to the parent directory.

    There are 2 ways to navigate. Either by using the full path or by using the relative path.

    Let’s say you are in /Users/user20378 . If you want to get to /Applications you can either navigate there using the full path cd /Application or the relative path cd ../../Applications .

    Depending on where you want to navigate the relative path can be more or less efficient than the full path.

    Use tab while typing the name of a folder or a file to auto complete.

    Источник

    Can I open files in TextEdit from the Terminal in Mac OS X?

    I frequently find that a Terminal command to open a file in TextEdit would be very handy. Does such a command exist on Mac OS X?

    5 Answers 5

    open -a TextEdit filename should do the trick.

    The -a flag specifies any application you want, so it’s applicable to any number of situations, including ones where TextEdit isn’t the default editor.

    Other relevant options

    • -t opens in the default editor (i.e. if you use BBEdit, TextMate, etc.)
    • -e will open the file specifically in TextEdit

    Direct, easy answer — add an alias to your

    The difference between this and the other answer, is you can easily remember it when you want it. Typing text and Tab to autocomplete it will make it instantly available

    For those with a bit more bash background, who want the reasoning without having to fuss with figuring it out:

    The problem is that a trivial symlink (or its ilk, like a shell script redirect) to /Applications/TextEdit.app/Contents/MacOS/TextEdit causes a new instance of TextEdit to open the file you pass to it. This works, but does not give your expected Mac OS X default behavior. (if you try it, you’ll see)

    To get the default UI behavior, using the Mac built-in open command, with that ‘-a TextEdit’ flag (that others mentioned) induces the Mac UI to have (any) currently running instance of TextEdit handle the call (with no inapropos ‘sudo’ needed for general case usage).

    Источник

    Читайте также:  Guid раздел для mac os
    Оцените статью