Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just had a Heisenbug that completely disappeared on me. I'm convinced that something funny must have happened when I compiled my program several days or a week ago.

But sadly, my Windows (MINGW) shell history buffer doesn't go back anywhere near that far. How can I arrange to log all my command-line activity so I can do these sorts of investigations in the future?

With Unix, of course, you can use the script utility. But windows does not (IME) treat files with the same care that Unix does: ie. you can't | tee logfile an arbitrary program and expect to interact with it normally. shell-windows do not represent themselves in a flexible pty interface. So based on this prejudice of mine, I haven't seriously searched for a port of the script utility.

How would a "windows" person do this?

share|improve this question
For the record, neither does Unix. Many interactive programs expect stdin and stdout to be a pseudoterminal (pty), which script provides, but a pipe would not. – grawity Jan 10 '14 at 21:18
oh. thanks. I don't think that changes the balance of my opinions. But I stand corrected in fact. – luser droog Jan 10 '14 at 21:22

Providing you're using bash, you may want to have a look at bash's HISTORY parameters to improve the size of your command-line history:

  • HISTSIZE changes the maximum number of commands available through the history command
  • HISTFILESIZE changes the maximum size of your HISTFILE, usually .bash_history. If not set, the HISTFILE won't be truncated at all, so you'll have your all-life history in it.
  • The histappend option appends the new history to your history file rather than overwriting it.

Example .bashrc:

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTTIMEFORMAT="%Y-%m-%dT%H:%M:%S%z  "

HISTTIMEFORMAT will timestamp your history, which is very useful when investigating.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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