summaryrefslogtreecommitdiff
path: root/i
blob: 1420dd54fd2d07a24ac87f5f9af0812d0bc35db0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash
set -e

readonly NOTES_DIRECTORY="${NOTES_DIRECTORY:-"${HOME}/notes"}"
readonly NOTES_PATH="${NOTES_DIRECTORY}/@inbox.txt"

if [ ${#} -eq 0 ]; then
    if [ -p "/dev/stdin" ]; then
        (cat; printf "\n\n") >> "${NOTES_PATH}"
    else
        eval "${EDITOR} '+normal G$' +startinsert " "${NOTES_PATH}"
    fi
else
    printf "%s\n" "${*}" >> "${NOTES_PATH}"
fi