Jump to content

Running Shell script


Recommended Posts

OK, I am sure I am being really dense here, but I decided to give Alfred 2 a go, and am struggling with Shell scripts. In Alfred 1, I just selected the shell script extension, pasted in what I wanted to run, and all worked. However, I can't figure out how to do the same in Alfred 2 - it is either more complicated, or it is staring me in the face and I can't see it. I am no good at scripting and such like and before was just pasting in terminal commands.

 

So for example, I have one to compact a sparse bundle, which in Alfred 1, I just put:

 

hdiutil compact /Volumes/BACKUP/Disk\ Backup/Macintosh\ HD.sparsebundle

 

That opened a terminal window with the command and ran it. 

 

I have now tried an apple script and normal script in Alfred 2, and neither open terminal or run the command. I know this is basic stuff, but can someone give me a few pointers? 

 

Thanks.

 

 

Link to comment

Let me try and help you out.

 

In the Workflows pane click the plus at the bottom then select Templates/Essentials/Keyword to Script. That will start out a blank workflow for you like in my screenshot.

 

screenshot20130203at649.png

 

Now double click the keyword section and enter whatever keyword you want... "compact" maybe? Also in that box select that you want no argument.

 

Now double click the run script box. Just paste your script in there and save.

 

That should do it. Now enter compact in Alfred and enter, then your script should run.

 

You can make it nicer by changing the workflow name and with a custom icon if you like.

Link to comment

If that is the case, then it is a possibility it is running. In Alfred 1 the terminal window opened and I could see what was happening, so I assumed it would open here as well. Is there a way to get it to open? I also have this one:

 

drutil cdtext

 

And the used to open up a text window with the CD tracks on - again it is not doing that.

Link to comment

I bet it is running and you just don't know it.  :)

 

On you second one... you could make a Workflow like this with Applescript that would pop up a Terminal with your results.

 

Or you could use the one you have with the bash script and have it output to "large type" in the workflow. That will popup a text window with the results.

 

 

 

tell application "Terminal"
activate
do script "drutil cdtext"
end tell
Link to comment

Thanks, that cd one works, but for some reason opens up 2 terminal windows which is mildy annoying - any way to stop that? And I did just the same with the other replacing the do script part with the compaction script and that now works - it couldn't have been running before, as when it finally did work, it managed to compact a few GB, so it hadn't before. Again, am getting 2 terminal windows. 

 

Again, thanks for the help - I like Alfred 2, but it is a shame some of the simple things that even I could do have no been replaced with more complicated ones that I have to ask for help on.

Link to comment

I'm not sure what you are doing differently than me, but I only get one Terminal window with this. ?

 

I have it with a keyword and no argument straight to the Applescript.

 

 

 

on alfred_script(q)
tell application "Terminal"
do script "drutil cdtext"
activate
end tell
end alfred_script

screenshot20130203at955.png

Link to comment
  • 4 weeks later...

Thanks very much, the script in the last posted sorted it! Shame it got more complicated in Alfred 2 though. 

 

v2 isn't finished quite yet - before it's finished, there will be a "Run Script in Terminal" action which will essentially be the same as a non-silent extension in v1 :)

Link to comment

Brilliant, thanks! I take it all back  ;)

 

This has now been added to b148 if you update.

 

Simply click the [+] button and select the "Essentials > Keyword to Terminal Command" template, set a keyword (set as no argument) and paste in your terminal command.

 

Simples *Squeak* :)

Link to comment

This has now been added to b148 if you update.

 

Simply click the [+] button and select the "Essentials > Keyword to Terminal Command" template, set a keyword (set as no argument) and paste in your terminal command.

 

Simples *Squeak* :)

 

Excellent, works like a charm! Thanks for adding it  :)

Link to comment
  • 2 months later...

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...