aboutsummaryrefslogtreecommitdiff
path: root/bin/clog.sh
blob: 1b612d68a7c71a567b6dd262b7599a3a475f3c44 (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
self=clog

# Ignore arguments
set --

# If we have rlwrap, quietly use it
command -v rlwrap >/dev/null 2>&1 &&
    set -- rlwrap --history-filename=/dev/null -C "$self" "$@"

# Write the date, the standard input (rlwrapped if applicable), and two dashes
# to $CLOG, defaulting to ~/.clog.
{
    date
    "$@" cat -
    printf '%s\n' --
} >>"${CLOG:-"$HOME"/.clog}"