Since you started off doing this by way of Terminal, here’s how you would complete the bash script to retrieve user input and utilise this for the name of a new folder being created:
cd /Users/stephen/Repositories
echo -n "Enter new folder name: "
read new_project_name
mkdir $new_project_name
All of this can go into a single Execute in Terminal action, as opposed to having one action per command and using a Pause in between.
If I may ask, is there are specific reason you chose to use the Execute in Terminal action to accomplish this ?
This works. But, is there a way to pause the macro until a new folder name is provided and the return key is pressed? At the moment I've added a 7 second delay to get this working.
My apologies, Stephen, it's because I don't have the Execute in Terminal action for some reason (was this a third-party add-on?), so couldn't test it precisely in the same way. But the reason it didn't work is because there ought to be semicolons terminating each command line:
cd /Users/stephen/Repositories;
echo -n "Enter new folder name: ";
read new_project_name;
mkdir "$new_project_name"
There should also be double quotes surrounding $new_project_name as an argument of mkdir to handle folder names with spaces:
But, the reason I asked why you were choosing to use this particular action to do this is because Keyboard Maestro provides the means with which to create folders in Finder:
it seems you are using an old version of my “Execute a Script in Terminal” plugin. Go here for the latest version, which allows you to use KM variables and is also updated for KM8. [1]
But for your purposes here you don’t need that plugin (unless I’m misunderstanding). It works better with the KM standard action “Execute Shell Script”:
(The sole purpose of my Execute in Terminal plugin is to run a shell script open in the Terminal, as opposed to the “normal”, hidden shell.)
[1] Before you download a macro or a plugin from a thread on the forum, it is always a good idea to scroll down towards the latest post in the thread of that macro/plugin. This is because when the author of the macro/plugin posts an update after a couple of weeks or so, he is no longer allowed to modify the original post. Hence you’ll find the latest versions of macros/plugins often in a separate, later post on the thread.
I downloaded Keyboard Maestro from the website, I’ve not installed any plugins - I’m just using the stock version of the software.
I’m still finding my feet with the software, so I’m most likely not using the best actions for what I’m trying to do.
I have a plan to create a much bigger action, for a set of tasks I do on a fairly regular basis. Part of that involves installing software via the Terminal.
It would be useful to know if an action can be paused until the return key is pressed.
This would allow me to remove the 7 second pause from my current macro.
I couldn’t initially get the action to work when the new folder name had any white space. test project output 2 folders, test and project
Your tip to add double quotes around the variable "$new_project_name" did the trick. However, for some reason when I typed the double quotes they didn’t work.
Not sure if it’s a setting on my Mac, or in Keyboard Maestro, but double quotes get converted to smart quotes - which doesn’t work. I had to copy and paste the quotes from your example.