Forums

Discuss all things Remember The Milk.

Adding Tasks from the Unix Command Line

manning999 says:
This probably applies to a very small audience, aka engineers and programmers who work in a Unix terminal (Linux, Solaris).

With Smart Add, you can mail your new task to your inbox email address from a shell, without having to leave the terminal and disrupt your flow. For example, if you are in the flow working and coding, and Bart asks you over the cube wall to test his code changes he just committed, you could enter the following line on the command line:

mail -s "Test code changes committed by Bart. ^tom @ 9a \!1 #Testing #na @Work" homersimpson+abc123@rmilk.com

First, the mail daemon must be up and running in order to send the email out. Your IT department can ensure this is the case.

Second, the -s option introduces the whole text in double quotes as the email's subject line.

Third, the "bang" character for priority would need to be escaped by a backslash, so that the shell (I'm assuming tcsh, BTW) does not interpret it as something else.

Finally, the properties in the example would cause the task "Test code changes committed by Bart." to be added to homersimpson's RTM account. In addition, the task will have a due date/time of tomorrow at 9:00 a.m., have a high priority, be added to the Testing list (assuming that list exists), be tagged with na (for next action), and be added to the location Work.

Again, I think a very small audience might find this convenient.
Posted at 5:26am on September 11, 2009
eddm says:
I'm pretty sure the bang is also used with bash too, so look out for that.

This could be pretty useful if combined with an Automator action on OS X. Bring up a quick text prompt, feed the input as arguments to the mail binary. Nice and lightweight - I like it :)

In fact, the same approach could be used with an Automator Service in Snow Leopard, thanks to Apple's new improvements to that area. Highlight text (perhaps in an email), right click it, "Add to RTM", feed THAT text into the mail command.

You've inspired me here, I might use my free weekend to play about and see if I can put together an elegant enough solution that way. (Until someone else tells me they've already done it)
Posted 14 years ago
eddm says:
Expanding on that, it is incredibly easy to turn into a very easy to use Automator Service in Snow Leopard (Mac OS 10.6).

Using this, you can right click any text and just select "Send to RTM" (or whatever you want to name it) to create it as a task in RTM (probably in your inbox, for you to prioritise and categorise later in a shallow GTD way).

Just fire up Automator, create a "Service" and ensure the drop down at the top reads "Service receives select TEXT in ANY APPLICATION".

Look under the "Utilities" action library and drag a "Run shell script" action into your workflow on the right. Use the bash shell (/bin/bash); it'll probably work just as well with the others, assuming you haven't customised the others to make this not work.

Change "pass input" to "as arguments", and paste the following into the textbox below:

mail -s "$1" username+abc123@rmilk.com

Replacing the email address with yours, obviously, that can be found in the "Info" tab on your settings page.

That $1 basically represents the first argument passed into your shell script here, which is going to be the text you've selected.

Save this service, call it whatever you want (this name will be what appears in your context (right click) menu or services menu) and -- assuming your settings at the top were correct, specifying that you are taking TEXT input from ANY application -- you should see this option when you right click any highlighted text. Hit that option, and you should see that text as a new task in RTM in a matter of seconds.

This is an incredibly simply action, but I'm sure will be very useful to me and everyone else. As stated in the OP, you MUST have a mail delivery daemon running on your machine; which it is by default on OS X. Chances are if you're turned it off, you know how to turn it on.

Passing this text in as an argument to the mail command will also negate the need to escape possible control characters such as the bang (!), so feel free to use whatever text you want in creating tasks this way.

Props to manning999 for alerting me to the simplicity of just using the mail command to throw these things into RTM :)
Posted 14 years ago
emily (Remember The Milk) says:
manning999 and eddm,

Both of your tips are very cool, so you're both Tips & Tricks Tuesday winners -- we've upgraded each of your RTM accounts to have a free year of Pro. :)
Posted 13 years ago
manning999 says:
Sweet! Thanks!
Posted 13 years ago
matthew.bassett says:
For the email it via the command line, it might be worth adding email aliases (/etc/aliases) to forward to your RTM email address via easier to remember local email addresses, i.e. if you are using a traditional mail transport agent (such as sendmail or postfix) insert into /etc/aliases file:

########### /etc/aliases ##########
rtm-task: fred+ab123@rmilk.com
rtm-task-list: fred+ab123+import@rmilk.com
##############################

(and then issue the 'newaliases' command as route)

Then your command line becomes the slightly easier to remember:

mail -s "Test code changes committed by Bart. ^tom @ 9a \!1 #Testing #na @Work" rtm-task

Or for a list of tasks:

mail -s "Inbox" rtm-task-list << EOFTASKS
Test code changes committed by Bart. ^tom @ 9a \!1 #Testing #na @Work
Review specification updates from Barney ^thurs \!2 #specs @Work
<< EOFTASKS

(or you can keep track of tasks to add in a text file in a similar way, and send that instead of using a 'here' document)

mail -s "Inbox" < task-list.txt

(where task-list.txt contains the same content as the above 'here' document)
Posted 13 years ago
matthew.bassett says:
Bother. That second '<<'' should of course not be there -- should be just a naked 'EOFTASKS'
Posted 13 years ago
stephdewit says:
I use the manning999 tip, but with a little improvement.

I created a small shell function which makes tasks adding from a shell easier.

Just edit your profile file (with Mac OS X it's ~/.bash_profile) and add these lines :

rtm() {
echo '' | mail -s "$*" homersimpson+abc123@rmilk.com
}

So after opening a new shell you can type :

rtm Test code changes committed by Bart. ^tom @ 9a \!1 \#Testing \#na @Work

[Note the bashslashes before the ! and # characters.]

And Homer will be happy to see the task added to his list.

Posted 13 years ago
kylesteinman says:
Can anyone tell the Unix-unsavvy and Automator relatively-unsavvy amongst us if there is a way to add to the Service a request for which day to put it on? (so that it can ask "What day?") and I can choose "today" or "tomorrow" or "Saturday" and it will add that to the end of the Subject line for the mail so that it gets put on that day?

Thanks!
Posted 13 years ago
pinkersmead says:
Tried using the automator tip but doesn't work. :(

I have mail running as a process.
Posted 13 years ago
babouyes says:
Hi there, I use Quicksilver to add tasks on mac, but what about windows(7). is there anything like that?

thank you!
Posted 13 years ago
kmgdroid says:
For those who dont have a mail server to push to, use msmtp (http://msmtp.sourceforge.net/) instead of mail to push directly to rmilk's smtp server !

pretty simple to install on Linux, just do a apt-get or yum ! Any one can chime in if msmtp is available for Macs ?

msmtp along with host:
msmtp -X - -f '<>' --host=$(host -t MX rmilk.com | sort -n -k 6 | cut -d' ' -f 7 | head -n 1) homersimpson+abc123@rmilk.com

msmtp along with dig:
msmtp -X - -f '<>' --host=$(dig rmilk.com MX +short | sort -n | cut -d' ' -f 2 | head -n 1) homersimpson+abc123@rmilk.com

Input methods of your tasks in your shell -

msmtp -X - -f '<>' --host=$(dig rmilk.com MX +short | sort -n | cut -d' ' -f 2 | head -n 1) homersimpson+abc123@rmilk.com
Test code changes committed by Bart. ^tom @ 9a \!1 #Testing #na @Work
Review specification updates from Barney ^thurs \!2 #specs @Work
and are key board commands

echo "my new task" | msmtp -X - -f '<>' --host=$(dig rmilk.com MX +short | sort -n | cut -d' ' -f 2 | head -n 1) homersimpson+abc123@rmilk.com

Note that there is no queuing, so it will either succeed or fail in realtime

you would see this when a successful message is sent -
Mon DD HH:MM:SS host=smtp-in01.l.rememberthemilk.com. tls=off auth=off from=<> recipients=homersimpson+abc123@rmilk.com mailsize=35 smtpstatus=250 smtpmsg='250 2.0.0 Ok: queued as xxxxxxxxxx' exitcode=EX_OK
Posted 13 years ago
joel.remigio says:
Tthis morning I implemented the Automator tip successfully. But now, my custom "Send to RTM" is no longer turning up in my right-click context menu.

Any thoughts?
Posted 13 years ago
johnwin says:
@manning999 & @eddm

Two fantastic tips!

Would either of you object to me re-posting these tips on my personal blog, with full credit and links of course?

My blog can be found here: www.johnwin.co.uk

Please let me know.

Posted 13 years ago
(closed account) says:
I totally agree. These are excellent tips as I am constantly looking for ways to speed up adding tasks.

Thanks for sharing!
Posted 13 years ago
manning999 says:
I personally have no objections. Blog away!
Posted 13 years ago
jdfalk says:
I've been playing with email in these same ways since about 1992, but I chose a different route for my command-line script because I wanted it to be closer to real-time:

---
#!/bin/bash

# Login information.
USERNAME="myusername"
PASSWORD="mypassword"
DMTO="rtm"
URL=http://twitter.com/statuses/update.xml
CURL=/usr/bin/curl

$CURL -u $USERNAME:$PASSWORD -d status="d $DMTO $*" $URL
---
Posted 13 years ago
jdfalk says:
(that's your twitter username & password, BTW)
Posted 13 years ago
tipclapper says:
Hey guys,

I just finished a little AppleScript app, which simply opens a dialog window, where I can enter my task name and stuff... I run it through quicksilver by typing "milk"...

To send the mail, I use the code above. But there is a issue with german umlauts.

For example: I have a list which is called "Bücher" (means books in english), which contains books I may want to buy.

When I send a mail like:
mail -s "myGreatBook #Bücher" adress@rmilk.com

the task will be displayed in the inbox list and has the tag bxxcher...

Can anyone help?

Thanks for sharing anyway!!!
Posted 13 years ago
janvanderploeg says:
I've tried the automator script. Didn't worked on my default MBP with default OSX 10.6. No failure message, no task in my rtm inbox.
Posted 13 years ago
klobass says:
@jdfalk

how exactly this should work?
Posted 13 years ago
aron.levendel says:
janvanderploeg +1

pls help! I'm afraid there is no mail delivery daemon running on my mac (exc 'Mail') ... thanks in advance
Posted 13 years ago
danwtmoon says:
@janvanderploeg +1
Posted 13 years ago
peterhol says:
@janvanderploeg +1

but I do think that we have a mail daemon running.. just open terminal and type "mail" - at least I got a "no mail for myuser" back... so I guess you just have to set it up somehow.
Posted 13 years ago
hekaplas says:
Here's how to set up your daemon running with gmail: http://www.riverturn.com/blog/?p=239

Can anyone help, when sending tasks from a console, the letters ä and ö are replaced with X-letters. When I send mail to i.e. gmail, they're ok. I've tried to change the encoding to utf-8 and iso-8859-1 with no luck...
Posted 12 years ago
Log in to post a reply.