stevef Posted February 3, 2013 Share Posted February 3, 2013 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
Weaselboy Posted February 3, 2013 Share Posted February 3, 2013 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. 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
stevef Posted February 3, 2013 Author Share Posted February 3, 2013 Hi and thanks for your quick reply. Unfortunately, that is exactly what I have already tried (and also with Apple script rather than bash one), but the command just isn't running at all. Nothing happens when I type in the keyword. Link to comment
Weaselboy Posted February 3, 2013 Share Posted February 3, 2013 If that exact command runs in Terminal, it should run from Alfred. With this workflow, you would get no feedback that it had run. Is it possible it is running/working and you just are not aware of it since there is no feedback? Link to comment
stevef Posted February 3, 2013 Author Share Posted February 3, 2013 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
Weaselboy Posted February 3, 2013 Share Posted February 3, 2013 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
stevef Posted February 3, 2013 Author Share Posted February 3, 2013 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
Weaselboy Posted February 3, 2013 Share Posted February 3, 2013 Sorry. This will do it in one Terminal window. tell application "Terminal" do script "drutil cdtext" activate end tell Link to comment
stevef Posted February 3, 2013 Author Share Posted February 3, 2013 Please don't apologise for helping! And thank you very much for the revised one. It still opens 2 windows, even if I take out the activate part. Don't worry, I am sure I can live with it. Again, thanks for your help. Link to comment
Weaselboy Posted February 3, 2013 Share Posted February 3, 2013 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 Link to comment
stevef Posted February 3, 2013 Author Share Posted February 3, 2013 Thanks. Have just copied you exactly and still get 2. One is directly behind the other, so if I move the top or cmd+W, the other is there. Maybe it is a setting in Terminal that I have differently. Link to comment
caiman Posted February 28, 2013 Share Posted February 28, 2013 Hi stevef. I have the same issue, and found this thread which may be helpful to you: http://hintsforums.macworld.com/showthread.php?t=68252#post362624 Weaselboy 1 Link to comment
stevef Posted February 28, 2013 Author Share Posted February 28, 2013 Hi stevef. I have the same issue, and found this thread which may be helpful to you: http://hintsforums.macworld.com/showthread.php?t=68252#post362624 Thanks very much, the script in the last posted sorted it! Shame it got more complicated in Alfred 2 though. Link to comment
Andrew Posted February 28, 2013 Share Posted February 28, 2013 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
stevef Posted February 28, 2013 Author Share Posted February 28, 2013 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 Brilliant, thanks! I take it all back Link to comment
Andrew Posted March 1, 2013 Share Posted March 1, 2013 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* caiman 1 Link to comment
stevef Posted March 1, 2013 Author Share Posted March 1, 2013 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
justingordon Posted May 12, 2013 Share Posted May 12, 2013 Works, but I'd like the terminal command to run in the same terminal. I'm simply trying to make an action called "ogen" that runs a bash function "ogen". (octopress generation). Any way to have this always run in one window? 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