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!