Jump to content

RunCommand — Run shell commands without opening a terminal


Recommended Posts

  • 2 weeks later...

Update.

 

Now even the option to run commands on selected files/directories will cd to the current Finder directory first. This is to allow commands that would create an output file to do it where you’d expect, instead of the workflow’s directory.

Edited by Vítor
Link to comment
  • 9 months later...
  • 2 weeks later...
  • 9 months later...
  • 4 weeks later...
  • 5 months later...
  • 1 month later...

Update.


It now uses notificator for notifications. Please tell me if something goes wrong (if you get any error or stop receiving notifications). If everything works fine, I’d also be interested in knowing.


Main reasons for the switch to notificator are in the DownVid post.


To update, download the latest version (same URL) or wait a few days (15 or less) and it’ll prompt you to on next usage, since it uses OneUpdater.

Edited by vitor
Link to comment
  • 2 years later...

The runcommand Alfred workflow is my favorite workflow by far. Unfortunately the latest update has stopped working with Alfred 3 on my machine. I get a message saying that I need to update to the latest version of Alfred. I checked and I'm on the latest version of Alfred 3, but not sure if I have done something wrong with the update or if runcommand only works on Alfred 4 now. Is it possible to get an older version of runcommand so that i can carry on using it or if you have any advice on how I could get this latest version running on Alfred 3.

 

Thank you.

Wes.

Screenshot 2019-11-19 at 09.19.24.png

Link to comment
9 hours ago, Wesley Martin said:

The runcommand Alfred workflow is my favorite workflow by far.

 

Thank you. And welcome to the forums.

 

9 hours ago, Wesley Martin said:

Unfortunately the latest update has stopped working with Alfred 3

9 hours ago, Wesley Martin said:

or if runcommand only works on Alfred 4 now.

 

Yes, it’s because I’ve made a small update and any change to a Workflow makes it incompatible with older Alfred versions. I make and release these for free, so I don’t have the bandwidth to keep separate versions around.

 

9 hours ago, Wesley Martin said:

Is it possible to get an older version of runcommand so that i can carry on using it

 

Download this version and remove the pink OneUpdater node. You’ll no longer receive updates.

Link to comment
  • 1 year later...

Hi,

I appreciate so much that finally a smart guy came up to fill the most annoying void of Alfred.

 

That said, after installed RunCommand and added '>' (with the option 'space' ticked'), I test it like this:
> env <Cmd>+Enter>

 

I expected to see an LargeType window filled with 'env' output, but nothing shown up.

 

I also tried some othering:

> /opt/local/x11/bin/xeyes <Enter>.

I expected to see an animated eyes shown up in an X window. Again, nothing happened.

 

> which eyes <Cmd>+<Enter>

I expected to see '/opt/X11/bin/xeyes' in a LargeType window, but nothing happened.

 

How can I be so unlucky?

(I'm running it in Alfred 4, Mac Studio)

Here added debug output of '> which xeyes'

[17:55:26.861] Logging Started...

[17:56:52.844] RunCommand[Keyword] Processing complete

[17:56:52.852] RunCommand[Keyword] Passing output 'which xeyes' to Run Script

[17:56:53.259] ERROR: RunCommand[Run Script] /var/folders/_j/_qtnjpj1345256smf04z2w8h0000z8/T/tmp.dfUizVYI: line 5: syntax error near unexpected token `newline'

/var/folders/_j/_qtnjpj1345256smf04z2w8h0000z8/T/tmp.dfUizVYI: line 5: `xargs -0 -J {} which xeyes < '

[17:56:53.266] RunCommand[Run Script] Processing complete

[17:56:53.267] RunCommand[Run Script] Passing output '' to Large Type

Edited by Monte Lin
Link to comment

Welcome @Monte Lin,

 

2 hours ago, Monte Lin said:

I appreciate so much that finally there is a workflow to run shell command without opening terminal (and why Alfred never comes to its mind to provide this functionality is beyond me).

 

The Workflow has existed since 2013, so “finally” doesn’t really apply! It’s also not a very popular Workflow (probably, I don’t have real numbers) because it’s not something people need that often. Plus, it requires weird solutions to get right in that many shells. All that makes it so it’s the right decision for Alfred not to have this natively. Alfred doesn’t load the user’s environment by design, it’s a feature. This is exactly what Workflows are for.

 

2 hours ago, Monte Lin said:

I expected to see an overlay window filled with 'env' output, but nothing shown up.

 

Works for me. Open the debugger, set the log output to “All Information”, perform the failing action, and post the output.

Link to comment
17 hours ago, vitor said:

Welcome @Monte Lin,

 

 

The Workflow has existed since 2013, so “finally” doesn’t really apply! It’s also not a very popular Workflow (probably, I don’t have real numbers) because it’s not something people need that often. Plus, it requires weird solutions to get right in that many shells. All that makes it so it’s the right decision for Alfred not to have this natively. Alfred doesn’t load the user’s environment by design, it’s a feature. This is exactly what Workflows are for.

 

 

Works for me. Open the debugger, set the log output to “All Information”, perform the failing action, and post the output.

 

Vitor, glad to meet you.

 

Here is the debug output by "> env <cmd>+<enter>"  (I also select 'all Workflows" in the debugger setting:

[13:15:17.504] RunCommand[Keyword] Processing complete

[13:15:17.506] RunCommand[Keyword] Passing output 'env' to Run Script

[13:15:17.849] ERROR: RunCommand[Run Script] /var/folders/ld/9n2t22k93hvgg3_kk6yl2mbw0000gn/T/tmp.xoZ8FNWj:6: parse error near `\n'

[13:15:17.854] RunCommand[Run Script] Processing complete

[13:15:17.855] RunCommand[Run Script] Passing output '' to Large Type

 

I tested several times, all with the same error except the last part of '/var/folders....' path were different.

I also got same error on X86 Mac.

 

Thanks for your help.

By the way, is RunCommand compatible with Alfred 5?

Edited by Monte Lin
Link to comment
6 hours ago, Monte Lin said:

By the way, is RunCommand compatible with Alfred 5?

 

Yes. Alfred 5 doesn’t break compatibility with older Workflows. There might be a couple of cases where a tweak is needed (e.g. new functionality added to an old object), but it won’t be big.

 

6 hours ago, Monte Lin said:

/var/folders/ld/9n2t22k93hvgg3_kk6yl2mbw0000gn/T/tmp.xoZ8FNWj:6: parse error near `\n'

 

Can you share the file’s contents?

Link to comment
On 7/26/2022 at 8:05 PM, vitor said:

 

Yes. Alfred 5 doesn’t break compatibility with older Workflows. There might be a couple of cases where a tweak is needed (e.g. new functionality added to an old object), but it won’t be big.

 

 

Can you share the file’s contents?

Sorry for the late followup.

The folder disappeared immedately afterward; I guess it's an auto-generated temporary. 

 

And thanks for the info.

Edited by Monte Lin
Link to comment

I plan to update the Workflow, so I’ll look at it then. No ETA. You’re the only one having the issue, so I don’t want to make changes now and break it for someone else. From a quick look, the temporary file shouldn’t be getting deleted and shouldn’t even have 6 lines.

Link to comment

I tried it again, the temp. file is available now:

#!/bin/zsh

setopt aliases

source /etc/profile; source /etc/zprofile; source /etc/zshrc; source /Users/monte/.zprofile; source /Users/monte/.zshenv;

cd '/Users/monte/Desktop/'

xargs -0 -J {} env <

 

The debug log is the same as previous:

[12:09:48.949] Logging Started...

[12:10:11.789] RunCommand[Keyword] Processing complete

[12:10:11.790] RunCommand[Keyword] Passing output 'env' to Run Script

[12:10:12.060] ERROR: RunCommand[Run Script] /var/folders/ld/9n2t22k93hvgg3_kk6yl2mbw0000gn/T/tmp.16WmCNXD:6: parse error near `\n'

[12:10:12.066] RunCommand[Run Script] Processing complete

[12:10:12.067] RunCommand[Run Script] Passing output '' to Large Type

 

The command I issued:

> env<cmd+Enter>

 

I run the 'xargs -0 -J {} env <' command generated by your workflow directly in shell; similar error occurred ("parse error near '\n'").

If I omitted the '<' , xargs waited for my input to continue:

==> If I then input "me=monte", the environment was echoed with 'me=monte' appended as the last line.

==> If I instead just press 'C-d' without input anything, nothing was printed.

I also tested the above in my MacPro (10.14, bash) and got same result.

I also tested the above in a Ubuntu Linux 18.4 VM (in Parallel Desktop); similar error and results.

 

Then, I tried adding ';' after the '{}' argument:

xargs -0 -J {};  env

xargs waited for my input.

==> I just press 'C-d' without input anything, environment is echoed as expected.

 

It seems xargs doesn't accept '<' redirection.

And I wonder why you need to indiscriminately pass user input to xargs? Isn't it up to user to determine if xargs processing is needed?

I believe if your generated command was just 'env' than we'll get expected result.

 

If for some reasons you think xargs is necessary, wouldn't the generated command 'env | xargs -0 -J {}' be more sensible?

 

Thanks your help.

Edited by Monte Lin
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...