Jump to content

Fitting Several Things into One Workflow


Recommended Posts

I'm brand new to Alfred, and I'm trying to put together a complicated 'open this giant project with one keyword'  workflow.  I've been able to implement pieces of the workflow, but I haven't been able to cram everything into one alfred keyword, which is what I want.

 

I want to type the keyword 'couch' into alfred, hit enter, and have it do the following:  

 

1. Open the 'my_couch' folder in sublime.  

2. Open a terminal, navigate to the my_couch folder, and start the rails server. 

3. Open a new terminal and start the Postgres server

4. Open google chrome, and have it navigate to 'localhost:3000'

 

This workflow opens up all the stuff I need to work on my ruby on rails project called 'couch.' 

 

The broad, overarching question is 'Is this workflow possible in Alfred?'  

 

Here are a couple more nitty gritty questions. 

 

For step 1, I have been able to link the keyword 'couch {filename here}' with sublime, using the file-filter input object. I've limited it to search for folders, and then I feed the resulting folder into the Open File object, which then opens the folder in sublime.  What bugs me about this workflow is that in order open the couch folder in sublime, I have to type 'couch my_couch,' where my_couch is the input folder.  I don't want to have to specify the folder.  I just want to type 'couch' and have it know that I want to open the couch folder in sublime.  

 

For step 2, I have had zero luck using the terminal command object to do stuff.  Is there a simple example workflow that shows how to get open a terminal and run 'echo "hello world"' to show how to open a terminal and run a script?  Also, does it actually open a terminal window, run the script, and leave it open, or does it do it magically in the background?  I would like it to open the terminal, run the script, and leave it open so that i can mess with stuff later.

 

Thank you!

 

Tara

Link to comment

I'm brand new to Alfred, and I'm trying to put together a complicated 'open this giant project with one keyword'  workflow.  I've been able to implement pieces of the workflow, but I haven't been able to cram everything into one alfred keyword, which is what I want.

 

I want to type the keyword 'couch' into alfred, hit enter, and have it do the following:  

 

1. Open the 'my_couch' folder in sublime.  

2. Open a terminal, navigate to the my_couch folder, and start the rails server. 

3. Open a new terminal and start the Postgres server

4. Open google chrome, and have it navigate to 'localhost:3000'

 

This workflow opens up all the stuff I need to work on my ruby on rails project called 'couch.' 

 

The broad, overarching question is 'Is this workflow possible in Alfred?'  

 

Here are a couple more nitty gritty questions. 

 

For step 1, I have been able to link the keyword 'couch {filename here}' with sublime, using the file-filter input object. I've limited it to search for folders, and then I feed the resulting folder into the Open File object, which then opens the folder in sublime.  What bugs me about this workflow is that in order open the couch folder in sublime, I have to type 'couch my_couch,' where my_couch is the input folder.  I don't want to have to specify the folder.  I just want to type 'couch' and have it know that I want to open the couch folder in sublime.  

 

For step 2, I have had zero luck using the terminal command object to do stuff.  Is there a simple example workflow that shows how to get open a terminal and run 'echo "hello world"' to show how to open a terminal and run a script?  Also, does it actually open a terminal window, run the script, and leave it open, or does it do it magically in the background?  I would like it to open the terminal, run the script, and leave it open so that i can mess with stuff later.

 

Thank you!

 

Tara

 

To answer your broad, overarching question: Yes, this is absolutely possible with Alfred :)

 

Here's a quick workflow I made; if I understood your post correctly, it should have every action you need.

 

Note that nodes 1, 2, and 3 have "/path/to/my_couch" in them. Obviously, these need to be replaced with the actual path to your 'couch' folder ;)

 

Since you obviously have some degree of experience with the command line, I'll ask you to please check the commands in nodes 2 & 3. I don't use rails or postgres, so I threw in some commands I found on the internet. If these aren't the commands you use, change them.

 

I also set the workflow to use "Sublime Text 2" in node 1. If you don't use this application, replace "Sublime Text 2" with the name of the application you use.

 

If you have more questions, make it known :P

 

Cheers, and welcome to Alfred  :)

Edited by Tyler Eich
Link to comment

To answer your broad, overarching question: Yes, this is absolutely possible with Alfred :)

 

Here's a quick workflow I made; if I understood your post correctly, it should have every action you need.

 

Note that nodes 1, 2, and 3 have "/path/to/my_couch" in them. Obviously, these need to be replaced with the actual path to your 'couch' folder ;)

 

Since you obviously have some degree of experience with the command line, I'll ask you to please check the commands in nodes 2 & 3. I don't use rails or postgres, so I threw in some commands I found on the internet. If these aren't the commands you use, change them.

 

I also set the workflow to use "Sublime Text 2" in node 1. If you don't use this application, replace "Sublime Text 2" with the name of the application you use.

 

If you have more questions, make it known :P

 

Cheers, and welcome to Alfred  :)

 

Thanks!  This is great! Thank you for the prompt reply and the useful answer!

 

It nearly worked.  I had an issue with the open URL node until I realized that I told you to navigate to localhost:3000 instead of http://localhost:3000

 

Once I fixed that typo, swiched the folders to the proper folder, and substituted in the right commands, it works like a charm!  Now instead of twenty clicks and several hundred characters to get my project up and running, I have seven keystrokes- one to open alfred, five to spell couch, and the enter key!  

 

I am now an Alfred convert.  

 

Here is the updated workflow.  

 

Now I'm all excited, and I have more questions.  

 

1. Is there a way to tell Alfred not to open the URL until after the terminal commands have been run?  As it stands, the website tries to open before the server starts running, so I have to hit the refresh button in my browser to actually show the page.  Not a big issue, but it would be nice to be able to delay opening the website until there is actually a website to open.

 

2.  Is there a way to open a folder in Sublime, and then have particular files open and ready to be edited in sublime?  For example, I have a file in my couchs folder called App.js. I want App.js to be open in sublime when I open the folder in sublime.  

 

Again, thanks!  Alfred is awesome!

 

Cheers,

Tara

Edited by tlroys
Link to comment

Thanks!  This is great! Thank you for the prompt reply and the useful answer!

 

It nearly worked.  I had an issue with the open URL node until I realized that I told you to navigate to localhost:3000 instead of http://localhost:3000

 

Once I fixed that typo, swiched the folders to the proper folder, and substituted in the right commands, it works like a charm!  Now instead of twenty clicks and several hundred characters to get my project up and running, I have seven keystrokes- one to open alfred, five to spell couch, and the enter key!  

 

I am now an Alfred convert.  

 

Here is the updated workflow.  

 

Now I'm all excited, and I have more questions.  

 

1. Is there a way to tell Alfred not to open the URL until after the terminal commands have been run?  As it stands, the website tries to open before the server starts running, so I have to hit the refresh button in my browser to actually show the page.  Not a big issue, but it would be nice to be able to delay opening the website until there is actually a website to open.

 

2.  Is there a way to open a folder in Sublime, and then have particular files open and ready to be edited in sublime?  For example, I have a file in my couchs folder called App.js. I want App.js to be open in sublime when I open the folder in sublime.  

 

Again, thanks!  Alfred is awesome!

 

Cheers,

Tara

 

I'm glad you're enjoying Alfred :)

 

I think it is possible to wait until a terminal command loads, but you have to use a command instead of the handy little Alfred URL node.

 

Try this:

  1. Create a new Output Script ([+ button] > Outputs > Run Script)
  2. In that output script, type/paste the command open "http://localhost:3000" -a "Google Chrome"
  3. Connect one of your Terminal Actions to this new Output Script.
  4. Also delete the 'Open URL' object so you don't get duplicate pages.

That should be it! I would connect it to the command that takes the longest. This is because the Output Script will only wait on one command, not both.

 

Unfortunately, I can't find a way to tell Sublime Text 2 to open a folder, then open a file from that folder in the same window :(. If it were possible with any degree of scripting, Alfred could do it; Sublime just isn't making such things available

 

Cheers :)

Link to comment

You could also background the server startup commands. It would give you fewer windows. Then, if you wanted, you could make another workflow (or add on to that one with a new keyword/argument) that would just kill the rails and postgres server.

 

To delay, look into the "sleep" command. So, just have it sleep for like two seconds. I haven't opened the workflow, so I don't  know which language you did it in, but for most, it's pretty much something like 'sleep(2);' or 'sleep 200' depending on whether the function interprets it as milliseconds or seconds.

 

Lastly, you could open the Sublime Text 2 with Applescript and then script the menus with System Events. You'd have to wait a second and not touch the computer while it blows through the menu commands for you... but it is possible.

Link to comment

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