4

I would like to expend some disk space recording all input and output to my terminal sessions; /usr/bin/script appears to be fairly good at that. I would like to make it so all new shell sessions (Currently I use/bin/bash) could start inside a script session that logged to a file by the name of say ~/.log/$(date --iso-8601=second).log

I've tried calling script at the end of my .bashrc file but recall it basically crashing and making opening a new shell impossible.

Any ideas on a possible way to keep this kind of record? I already have an "Eternal bash history" but just knowing the inputs is not always enough for me.

2

I don't think putting it at the bottom of your rcfile would do much good - all of the state you declared beforehand would get wiped out when script loaded a new shell until it tried to load the rcfile and etc and etc forever. I just made it work on my terminal like:

$ x=;bash --rcfile /dev/fd/3 3<<\$x
    export S_LOG=~/".log/$(date --iso-8601=second).log"
    exec   script -aeqfc "bash   --rcfile /dev/fd/3 -i" "$S_LOG" \
3<<""
    alias success='echo it worked'
    PS1='script $ '
    exec 3<&-

$x
script $ success
it worked
script $ cat "$S_LOG"
Script started on Mon Dec 14 15:43:28 2015
script $ success
it worked
script $ cat "$S_LOG"
script $

And so I think you'd do better to locate it at the head of your rc-file, and then exec a new shell to read the rest of it after the point you call the new shell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.