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?

  • 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. Jan 10, 2014 at 21:18
  • oh. thanks. I don't think that changes the balance of my opinions. But I stand corrected in fact. Jan 10, 2014 at 21:22

2 Answers 2


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.


Use a shell buffer in emacs. The size of the buffer is then not related to the number of lines saved by the terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .