aboutsummaryrefslogtreecommitdiff
path: root/bin/clog.sh
blob: b17ff1c5d36fbb579c2df80e610fc8fc36074233 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh
# 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 -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}"