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?


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.

  • Thanks! This set me in the right direction, with some minor tinkering. I now have this line in my .zshrc file: function reminder () {automator -i $1 add_reminder.workflow} Works perfectly. – zoned post meridiem Sep 13 '13 at 14:13
  • Wanted to add that after playing with the syntax a bit, I realized that it also works without adding the 'function' part at the beginning of the line (i.e., it works precisely like Atanas suggested it would with his code) – zoned post meridiem Sep 13 '13 at 22:03
  • I am trying to type weather() { curl -4 http://wttr.in/$1 } to enable weather newyork alias, the original command is curl -4 http://wttr.in/newyork – Zigii Wong Feb 22 '16 at 9:23
  • @Wongzigii: (1) You've missed ; between $1 and } (2) It's better to use ${1:-newyork}, in this case if you start weather, newyork is used by default, and you can specify additional parameters if you want override it; (3) you don't need -4 anymore, it works even so no; (4) I would suggest use wttr instead of weather for the function name: it's short and unique and it's obvious what it means – Igor Chubin Feb 23 '16 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .