How to run a command that requires user input through oh-the-zsh alias

automatorcommand lineremindersterminalzsh

I'm trying to add Reminder.app items through the command line by invoking an alias. I use the Automator workflow solution from this question: How can I add reminders via the command line?, which invokes a basic workflow containing an empty Reminders item, via the following command line input:

automator -i remindertext add_reminder.workflow

This works perfectly, but is clumsy to type, so I want to set an alias for it. My question is: how do I set an alias in .zshrc that allows for me to set the reminder item text when I invoke the alias? It would basically need to be able to replace 'remindertext' with a variable, like so:

alias reminder='automator -i <variable> add_reminder.workflow'

Is this possible in zsh/oh-my-zsh?

Best Answer

Aliases are used as a shortcuts - sipmple commands that expand to longer ones. If you need to pass an argument to it, you would need to create a function. Maybe try something like:

reminder () { automator -i $1 add_reminder.workflow' }

Here $1 will expand to the first argument that you've passed to the function. So you'll to do something like:

reminder "Buy potatoes"

P.S: I haven't tried it, since I don't have zsh with me right now, so if it breaks, give me a shout.