3 if command -v script &> /dev/null;
8 TIMESTAMP="$(date '+%Y-%m-%d-%H:%M:%S')"
10 # The trick here is to use 'type' to eat any leading environment variables
11 # and get to the command name.
13 COMMAND_NAME="$(type -P "$@" 2>/dev/null | cut -d ' ' -f 1)"
15 [ "x$COMMAND_NAME" = "x" ] && return 1
17 # Escape the argument so that it can be reused as shell input
18 # NOTE: this is Bash specific.
20 COMMAND_ESCAPED=$(printf "%q " "$@")
22 script -q -e -c "$COMMAND_ESCAPED" "${TIMESTAMP}_$(basename "$COMMAND_NAME").log"
24 complete -F _command record