aboutsummaryrefslogtreecommitdiff
path: root/bin/clog.sh
blob: 81bfd744b5fe79ca2bb8ff130eecfdbf9bf5e101 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Record a timestamped message to a logfile, defaulting to ~/.clog
self=clog

# Build the cat(1) command we'll run, wrapping it in rlwrap(1) if available and
# applicable.
if [ "$#" -eq 0 ] && [ -t 0 ] && command -v rlwrap >/dev/null 2>&1 ; then
    set -- rlwrap --history-filename=/dev/null cat -- "${@:--}"
else
    set -- cat -- "${@:--}"
fi

# Write the date, the input, and two dashes to $CLOG, defaulting to ~/.clog.
clog=${CLOG:-"$HOME"/.clog}
{
    date
    "$@"
    printf -- '--\n'
} >> "$clog"