crisb Posted March 27, 2013 Share Posted March 27, 2013 DTerm is useful and nice enough that it probably doesn't exactly need replacing. But as since finding Alfred I've been able to ditch so many other little utilities, I'm just wondering if it would be feasible to write a workflow that would do DTerm's job. I'm a developer, but have a genetically-predisposed horror of AppleScript, so don't offhand know if this is feasible. Would be interested in opinions. DTerm is a great little app that allows you to run shell commands from its own mini-terminal, but the magic is that it sets its working directory to wherever the frontmost app window's open document is located. Which is great -- you can, for example, be in an editor/IDE, pop up DTerm (with a keyboard shortcut) and run git commands from the directory of the file you're currently editing. It can also optionally run a command in a real Terminal (or iTerm) window if desired. Could this functionality be replicated in an Alfred workflow? Link to comment
ctwise Posted March 27, 2013 Share Posted March 27, 2013 DTerm is useful and nice enough that it probably doesn't exactly need replacing. But as since finding Alfred I've been able to ditch so many other little utilities, I'm just wondering if it would be feasible to write a workflow that would do DTerm's job. I'm a developer, but have a genetically-predisposed horror of AppleScript, so don't offhand know if this is feasible. Would be interested in opinions. DTerm is a great little app that allows you to run shell commands from its own mini-terminal, but the magic is that it sets its working directory to wherever the frontmost app window's open document is located. Which is great -- you can, for example, be in an editor/IDE, pop up DTerm (with a keyboard shortcut) and run git commands from the directory of the file you're currently editing. It can also optionally run a command in a real Terminal (or iTerm) window if desired. Could this functionality be replicated in an Alfred workflow? Some of it. DTerm uses the Accessibility API and Scripting Bridge to determine the path for the front-most app. You'd have to rip the code from DTerm (https://github.com/bdrister/dterm) that gets that front-most path or selected files in Finder/PathFinder and create an executable that spits out the path(s). Wire up an Alfred hotkey to that code and do what you like with the results. Link to comment
ClintonStrong Posted March 28, 2013 Share Posted March 28, 2013 Here you go: dterm-ish.applescript I'm playing around with making this into a workflow, so you can run scripts in the background and get file/command suggestions while you type. It's not ready yet, but hopefully that custom terminal script holds you over for now. Link to comment
crisb Posted March 28, 2013 Author Share Posted March 28, 2013 Some of it. DTerm uses the Accessibility API and Scripting Bridge to determine the path for the front-most app. You'd have to rip the code from DTerm (https://github.com/bdrister/dterm) that gets that front-most path or selected files in Finder/PathFinder and create an executable that spits out the path(s). Wire up an Alfred hotkey to that code and do what you like with the results. Thanks, I didn't know the DTerm source code was available. Must have a look through it when I have a moment. Link to comment
crisb Posted March 28, 2013 Author Share Posted March 28, 2013 Here you go: dterm-ish.applescript I'm playing around with making this into a workflow, so you can run scripts in the background and get file/command suggestions while you type. It's not ready yet, but hopefully that custom terminal script holds you over for now. That's a terrific start, thanks. Look forward to anything further you do along these lines. Be sure to tweet about them! Looking through the code tends to confirm my Applescript prejudice. It's very readable, but it triggers memories of trying to write applescripts, and it seeming more like a trial-and-error process ("which Englishy locution works where?") than any other programming language I've ever tinkered with. Link to comment
joncrooke Posted February 9, 2014 Share Posted February 9, 2014 Here's a small tweak of Clinton Strong's script for iTerm2 support: https://gist.github.com/itsthejb/8900078 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now