Jump to content

Processing multiple files from a bash script


Recommended Posts

Hi - I'm a relative Alfred newbie, so apologies if this is obvious or answered somewhere that I missed!

I'm trying to run a bash script which outputs a number of file names, and then allow the user to act on those files, like they would on the results of a normal search - opening the file, revealing it in finder, etc.  (The script is running a custom `ripgrep` command - similar to `grep -l` - which just spits out matching filenames)

But I can't work out how to get the results of the script to be treated as multiple files - if I pass it to (say) the "File Buffer" action, which sounds like it might be what I want, it does nothing - and from looking at the debugger output, it seems like my bash script output is treated as one large string, instead of a number of separate lines.

 

Is this possible?  Would it help if the output was JSON not lines? (I could pipe it through `jq` if I needed JSON)

 

At the moment I have switched to running it in a terminal, which is good enough for now - but it feels like it'd be nice to be able to integrate this sort of thing into Alfred more completely.

Link to comment
5 hours ago, Korny said:

if I pass it to (say) the "File Buffer" action, which sounds like it might be what I want, it does nothing

 

It must be doing something, namely adding it to the File Buffer. Otherwise it must be outputting something to the debugger.


Separate the full paths to the files by tabs, so Alfred understands it’s several and connect it to an Action in Alfred Action, which seems to be what you want.

Link to comment
2 hours ago, vitor said:

Separate the full paths to the files by tabs

 

You should be able to use a JSON array since Alfred 4.1. It's not yet documented, as it was added kinda last minute and support might not be complete. The File Buffer action definitely supports it, as that's why support for multiple arguments was added IIRC.

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