Jump to content

Recommended Posts

Short version

Is there an equivalent to terminal's compgen autocomplete in runscript?

 

Long version

I work in an office with a shared NAS drive. All our clients take a very specific folder structure. It's kind of a pain in the ass to jump to a particular clients folder as we multi-task a lot.

 

All our client folders start with the first four letters of the client name as a client code.  So Super Dooper Client would be SUPE_Super Dooper Client - which is cool for autocompletion as it always knows where to go, since no two are the same (by chance to be fair, we've had to use acronyms for a couple, but we can remember those)

 

I've written this script in terminal to jump to the right folder, but it leaves me with an annoying terminal window open. I don't want to quit terminal completely, just close the active window. I can't see how to do that  (I've tried quit and exit, neither worked) - but I did see I should probably use a Run Script. Problem is I can't get the compgen autocomplete to work.

 

Here's the code:

 

src="{query}"
 //first go the right folder - an automatically mounted AFP drive
 cd /Volumes/Files/Clients/;

 //now automatically complete the file name from the 4 letter code I've typed in as the a query
 //this is the bit that doesn't work in a run script
 folder=$(compgen -d {query}_);

 //set the target folder	
 target="/Volumes/Files/Clients/$folder"

 // go to it
 cd "$target"

 //open it
 open .

 

thanks!

 

Share this post


Link to post
12 minutes ago, JorgeLuisBorges said:

Is there an equivalent to terminal's compgen autocomplete in runscript?

 

Have you looked into using a Script Filter or even a File Filter?

Share this post


Link to post
Posted (edited)
11 minutes ago, deanishe said:

 

Have you looked into using a Script Filter or even a File Filter?

nope...

I've never had any luck with those with mounted drives. My alfred scripting knowledge is pretty basic....

 

edit - done a quick look.

File filters seems for opening specific files, which we don't want, we want to open the folder. I'm probably missing something. 

Script Filters - if I read it correctly  - convert your input into a result built from json data? doesn;t seem right

Edited by JorgeLuisBorges

Share this post


Link to post

I think you've misunderstood how Filters work.


Their purpose is to show the user a list of items to choose from. Files or folders in the case of File Filters, and items specified by your own script in the case of Script Filters.


They're for selecting items, not doing stuff to them. What happens to selected items is up to you.


A File Filter might not work for you because your NAS-drive probably isn't Spotlight-indexed (meaning Alfred can't see the files, either).


But you can write a Script Filter that displays a list of all your client directories in Alfred for you to choose from.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...