I would like to tee output of every interactively executed command to a series of separate log files, one for each command. To do so, I have written the following script which will be set up as the last thing to run on shell startup (the end of .bashrc):date=$(date +%Y-%m-%d_%H-%M-%S)randstr=$(cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c 4)dir=~/log/${date}_${randstr}mkdir $diri=0while :do    read -e -p user@host:$(pwd)\$  cmd    eval $cmd 2>&1 | tee \${dir}/${i}-${cmd}\     (( i++ ))doneHowever there are some problems with this. First of all, this will stop reading as soon as a newline is encountered, simply because that's how read works. I don't want this behavior. I want it to behave exactly as a shell, so that for example when I write ls && and press Return, it will wait for more input before executing anything.How can I achieve this? Is it possible/feasible to achieve this with shell scripting? Should I use a more conventional programming language? Should I even patch bash to achieve this?
Save output of every command to separate log files?
bash;io redirection