Open current folder in Terminal


#1

Hey there!

I’m new at programming but I’m trying my best to learn as much as I can. In this moment I’m wondering how I could open a current folder I’m in with terminal (Mac) in order to avoid typing the whole path in the command line. Could anyone help me in this way?

Thank you so much in advance.


#2

Ricard, do you mean:

  1. You are looking at the Folders in your Finder, as in you are visually seeing a folder Icon?
  2. You want to then go “open a terminal here”?

On OSX you can just drag the folder to the terminal with your mouse and it will type the path there.

On Windows I think you can do that, and you can also right click and select “open powershell here”, but don’t quote me on that. I’m not at my windows machine right now.


#3

Hi @zedshaw!

I was thinking about 2, “open terminal here”. Is there any other option rather than the drag-and-drop?

Thank you so much Zed.


#4

Edit - Just tried this and it works a treat. Really nice on long dropbox folders:


#5

Thank you so much @gpkesley! That was what I was looking for. I’m now wondering which shortcut could work with this.

Taking advantadge of this topic I would like to ask if there’s a way to add Terminal in the toolbar (I don’t know how to add an app in the tool bar however) and click it to Open terminal here. Maybe that’s too much but it would be a nice option to avoid right-click and so on.

Thank you so much again.


#6

What do you mean by toolbar? The dock?

If so just drag and drop the terminal from the Applications/Utilities folder into the dock and let it go.


#7

Yes, for the dock you can also:

  1. Open terminal
  2. After it’s running, you’ll see it in the Dock. Just right click on the Dock icon and select “keep in dock”.

Also, if you want to do the inverse of “Open terminal here” you can do:

open .

When you’re inside terminal and it will open the current directory in Finder.

You can actually give it anything and it will try to open it. Video files, directories, paths to images, anything. Try it.


#8

@gpkesley, @zedshaw, thank you for your help once again.

Sorry I forgot to post a screenshot of what I understand as toolbar (marked in magenta). Find it attached.

Thank you in advance!


#9

You can’t. If you look at Finder > View > Customise Toolbar, you can add navigational controls and shortcuts but not applications.

To be honest, getting familiar with command line and Terminal is about moving away from interacting with the GUI and becoming more confident with text commands. Zed’s shortcuts certain speed that up too.


#10

Thank you @gpkesley. Missed that on my mac! Thank you @ricard for asking this.


#11

Thank you @gpkesley. Missed that command on my mac! Thank you @ricard for asking this.