aboutsummaryrefslogtreecommitdiff
path: root/bin/clog.sh
blob: 3269c5087dfe80ef022ef0e46b3e02873372138e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Record a timestamped message to a logfile, defaulting to ~/.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"