John Lindquist: Project Name Generator is a package which can be used as a CLI. Once you install it globally, you can invoke it with these options. I'm going to invoke project-name-generator -a -o with "dashed" passed in to give me a generated project name.
In Alfred, if I open my Preferences, and I go into my Workflows, I'll create a new Blank Workflow. We'll give this a name of Project Name Generator, say that it generates project names, tack on a projectnamegenerator to our Id, hit Create.
We want our initial trigger to be a Snippet. The keyword is going to be pn for project name. You can make that anything. I'm leaving my prefix empty and making my suffix ,, which will trigger that keyword. We'll hit Save there.
Then the action we want it to take is to run a script. We can simply take what we wrote out here, copy this and paste it in here. The one thing we have to do before this runs is to source our zshrc file and set the language to zsh. This way, it can pull in the environment variables and the required things from Node.
If you are missing this line, it would just have an output as this as text. With this line, it'll run this command with these arguments. I'll hit Save here.
The output here is going to be Copy to Clipboard. The query is just the result from the previous step. The result from here will be the input here to copy to the clipboard. Then the final step is an output of Dispatch Key Combo. We want it to paste, so just Command-V, hit Save, and then go here.
The steps are pn,, invokes this script which generates a name which copies it to the clipboard which then pastes it out, meaning that anywhere on my computer -- I'll type in Chrome right here pn,, -- you'll see it generated funny-fall. Do that again, pn,, disgusting-design, or even in here pn,, serene-step. That snippet should work anywhere you need it.
As a final step, we'll open this back up, do an image search for a generator, come over here, grab a generator, drop it right here just so it looks a bit nicer.