Sal
Peter Hoffmann Director Data Engineering at Blue Yonder. Python Developer, Conference Speaker, Mountaineer

send notes to simplenote from the command line and vim

sn.py is a command line app to send text to simplenote service. It uses the simplenote.py library.:

#!/usr/bin/env python
"""simplenote command line app"""

import sys
import fileinput

from simplenote import Simplenote
sn = Simplenote("XXX", "XXX")


def send(txt):
    note = {'content': txt}
    note, status = sn.add_note(note)

    if status != 0:
        print >> sys.stderr, note
        sys.exit(1)


def read_until_dot():
    line = raw_input()
    while line != ".":
        yield line
        line = raw_input()

import sys
def main(argv=None):
    if argv is None:
        argv = sys.argv

    if len(argv) == 1:
        lines = read_until_dot()
    else:
        lines = fileinput.input()

    send("\n".join(lines))


if __name__ == '__main__':
    main()

Usage

Enter a note:

$ sn.py
write text
you want to send to simplenote
end note with one . in line
.

Pipe the output from another commant to simplenote:

$ echo "send output from command" | sn.py -

Send the contents from a file to simplenote:

$ sn.py some_text_file.txt

Vim

There is the simplenote.vim plugin. It lets you interact with simplenote. If you just want a quick way to send notes to simplenote use the following commands:

Send the current buffer to simplenote:

:%w !sn.py -

Send the current selection to simplenote:

:'<,'>w !sn.py -