Mac os open terminal in current directory

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 or quit Terminal on Mac

    Each window in Terminal represents an instance of a shell process. The window contains a prompt that indicates you can enter a command. The prompt you see depends on your Terminal and shell preferences, but it often includes the name of the host you’re logged in to, your current working folder, your username and a prompt symbol. For example, if a user named michael is using the default zsh shell, the prompt appears as:

    This indicates that the user named michael is logged in to a computer named MacBook-Pro, and the current folder is his home folder, indicated by the tilde (

    Open Terminal

    On your Mac, do one of the following:

    Click the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal.

    In the Finder , open the /Applications/Utilities folder, then double-click Terminal.

    Quit Terminal

    In the Terminal app on your Mac, choose Terminal > Quit Terminal.

    Quit a shell session

    In the Terminal app on your Mac, in the window running the shell process you want to quit, type exit , then press Return.

    This ensures that commands actively running in the shell are closed. If anything’s still in progress, a dialogue appears.

    If you want to change the shell exit behaviour, see Change Profiles Shell preferences.

    Источник

    How to Launch Terminal in the Current Folder Location on Mac

    Often while working with local files you may need to open a Terminal window in your current folder location. While doing that is as easy as pressing a button and clicking an option in Windows, things are different on a Mac. You are required to first enable an option in your Preferences panel, and then you will have the option to launch an instance of Terminal in any folder of your choice on your Mac.

    A local instance of Terminal lets you execute commands while keeping the files in that folder in mind. It lets you work with the files right there in that folder.

    Here’s how you can launch Terminal in the current folder location on your Mac.

    Launching a Terminal Window in the Current Folder on a Mac

    You do not need a third-party app to get the job done. All you need to do is visit the Preferences panel, tweak a few settings here and there, and you will be all set.

    1. Click on the Apple logo in the top-left corner on your Mac, and select “System Preferences…” You will be taken to the Preferences panel on your Mac.

    2. Click on “Keyboard” in the Preferences panel.

    3. Once in the Keyboard panel, click on the “Shortcuts” tab.

    4. In the Shortcuts panel, click on “Services” in the left-hand menu. Scroll down in the right-hand menu, and select the options that say “New Terminal at Folder” and “New Terminal Tab at Folder.” These options should be next to each other.

    Click on “none” next to “New Terminal at Folder,” and press a key combination on your keyboard to assign a new shortcut key to the feature. That way you will be able to launch a Terminal window using a shortcut key instead of pulling up the menu and selecting the option to launch one.

    5. Once you have enabled the options and assigned a keyboard shortcut, you can close the Preferences panel.

    6. Open the parent directory where your folder is located. Then single-click on the folder where you wish to launch a Terminal window, click on “Finder” followed by “Services,” and select “New Terminal at Folder.” Or you can simply press the keyboard shortcut that you assigned before.

    7. A new Terminal window should launch in the current folder location allowing you to play around with the local files in that folder.

    Launching a local instance of Terminal should now be easy for you. Should you ever wish to disable the feature, you can do so from the Preferences panel by just unchecking the boxes that you selected in the above steps.

    Conclusion

    If your work revolves around working with local files using Terminal, and you do not want to go through the hassle of providing full paths to the files, you can simply use the above workaround to have Terminal launched keeping your current folder as its current working directory.

    Mahesh Makvana is a freelance tech writer who’s written thousands of posts about various tech topics on various sites. He specializes in writing about Windows, Mac, iOS, and Android tech posts. He’s been into the field for last eight years and hasn’t spent a single day without tinkering around his devices.

    Источник

    How to open Terminal in a directory on macOS

    Apr 25, 2019
    Comment

    When you run commands in Terminal, you may need to run them in a particular folder on your system. You can use the cd command to go to any folder you want to work in. If you want a faster way to open Terminal in a directory, you can use a free, open source app called OpenInTerminal. It’s a Finder add-on that can open Terminal in the current folder with the click of one button.

    Open Terminal in directory

    Download and run OpenInTerminal. Run the app and grant it the permission it needs to run. You will first be prompted to select which app you use to access the Terminal. The options it offers are; the default Terminal app, iTerm, and Hyper.

    After you select the default Terminal app, you will be asked to give the app the special permission it needs to run. Next, move the app to the Applications folder. Finally, hold down the Command key and drag and drop the app icon on to the Folder’s toolbar. Once it’s added, it will appear on the toolbar whenever you open Finder.

    To open Terminal in a folder, all you have to do now is click the button that OpenInTerminal added. Doing so will open the app and you can run commands in it.

    Removing the app

    Removing OpenInTerminal is simple enough i.e., you delete it from the Applications folder however, you have to first remove it from the Finder toolbar. To do that, open Finder and go to View>Customize toolbar in the menu bar.

    When the customization panel appears, click and drag OpenInTerminal’s icon out of the toolbar and drop it onto the panel. That will do the trick.

    Using the CD command

    Using the CD command in Terminal is pretty easy and it follows the same syntax that you use on Windows in the command prompt.

    Syntax

    Example

    While we’re on the topic of Windows and Command Prompt, you can easily open a command prompt in any folder on Windows 10 by typing cmd in the location bar in File Explorer. It doesn’t run with admin rights which makes it less useful but it’s a neat trick nevertheless.

    With Terminal, when you run a command that requires admin rights, you’re asked to enter the password to the admin account. In some cases, it may not work and you may have to open Terminal the traditional way and cd to the folder you have to work in.

    Leave a Reply Cancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Источник

    [Mac OS X] Открываем терминал в выбранной папке

    Из серии простых советов

    Если вместо смены текущего каталога командой cd , есть желание открыть Терминал.app, так чтобы текущим каталогом сразу была какая-либо папка, можно добавить в пункт Службы, вызываемый из контекстного меню нужной папки, соответствующую функциональность.

    Для этого открываем Системные настройкиКлавиатураСочетания клавиш, выбираем пункт Службы, в нем находим раздел Файлы и папки, в котором активируем соответствующие пункты (выделено красным):

    После чего, эти пункты появятся в Службах контекстного меню всех папок. Например (выделено красным):

    При выборе первого из них, откроется новая вкладка в окне уже запущенного Терминал.app, а при выборе второго откроется его новое окно. И в том и другом случае, текущем каталогом будет та папка, из контекстного меню которой был выбран один из этих пунктов:

    В чем можно убедиться, например, командой pwd как показано на картинке.

    Новости, статьи и анонсы публикаций

    Свободное общение и обсуждение материалов

    Лонгриды для вас

    В iOS есть скрытый механизм, который позволяет изменить ориентацию экрана, даже не поворачивая сам iPhone или iPad. Такая штука пригодится, если акселерометр в вашем устройстве прикал долго жить и перестал отзываться на ваши команды

    Apple выпустила уже третью бета-версию iOS 14.6 для разработчиков и участников программы открытого тестирования. Несмотря на то что это крупное обновление, оно содержит всего два нововведения

    Apple объявила о планах выпустить обновление с функцией бесконтактного управления Apple Watch. Благодаря ему часы смогут распознавать жесты, и для взаимодействия с ними не нужно будет прикасаться к экрану или кнопкам

    Источник

    Читайте также:  Mac os color sync
    Оцените статью