diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 901507c2..96ac97b3 100755 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -157,10 +157,13 @@ def cli(manual_args=None): journal = Journal.Journal(journal_name, **config) if mode_compose and not args.text: - if config['editor']: + if not sys.stdin.isatty(): + # Piping data into jrnl + raw = util.py23_read() + elif config['editor']: raw = get_text_from_editor(config) else: - raw = util.py23_input("[Compose Entry] ") + raw = util.py23_read("[Compose Entry, press Ctrl+D to finish writing]\n") if raw: args.text = [raw] else: diff --git a/jrnl/util.py b/jrnl/util.py index 727f6043..d461015b 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -65,10 +65,14 @@ def prompt(msg): msg += "\n" STDERR.write(u(msg)) -def py23_input(msg): +def py23_input(msg=""): STDERR.write(u(msg)) return STDIN.readline().strip() +def py23_read(msg=""): + STDERR.write(u(msg)) + return STDIN.read() + def yesno(prompt, default=True): prompt = prompt.strip() + (" [Y/n]" if default else " [y/N]") raw = py23_input(prompt)