Jump to content

Run Terminal Command in current Finder directory


Recommended Posts

Most certainly about a dozen people have done this already, but being too lazy to look these up I made my own  :)

 

cdh_git-status.png

 

 

Use Keyword "cdh" to cd into your currently open Finder directory. 
To run a Terminal Command , use "cdh [your command]".
If there is no folder currently open in Finder, your command will be run in your Desktop folder.
The Workflow will look for a non-busy Terminal window and use it before opening a new one.
 
 
Edited by franzheidl
Link to post
  • 1 month later...

Update:

 

The workflow will by default execute your command in the first non-busy Terminal window it finds, otherwise open a new one.

 

I have just added the option to explicitly run the command in a new Terminal window, just press [alt] when firing your command in Alfred 2.

 

Either pull from https://github.com/franzheidl/alfred-workflows.git, or use the updated downlowd link: http://cl.ly/NjL6

Edited by franzheidl
Link to post

Well spotted! 

This did slip through since it doesn't break the resulting behaviour, except for the double ampersands being piped through to the Terminal.

Just fixed this, pull from 

 

https://github.com/franzheidl/alfred-workflows.git

 

or use the updated download link:

 

http://cl.ly/NjL6

 

 

(also updated the ldownload links in previous posts)

Edited by franzheidl
Link to post

How difficult would it be to adapt this to work with applications other than Finder -- ie. to open/start a terminal session in the directory where the frontmost application's currently-open document (if it has one) is located?

 

This might make it possible to replace Dterm (since Alfred seems to be replacing so many of my other tools, why not?).

Link to post

Shouldn't be too difficult I think. Will give this a go next week, I'm currently away without my machine.

Do you imagine this more like a workflow of its own, an additional keyword/modifier to this one, or even as default behavior in case Finder is not the frontmost application?

Link to post

@franz: Thanks. I was thinking in terms of this being the default behaviour.

 

However before spending any time on this you might want to check out a related thread where someone's already posted something very close to what I'm after. It doesn't re-use existing Terminal windows like your workflow does, but is very functional as-is.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...