4

For the purposes of looking at which commands I am using the most, I'd like to keep a record of command I type in my bash history (even duplicates).

But, for sanity and ease of use, I still want to keep my ignoredups setting on.

Is there a way to automatically create two history files? With the "default" being no duplicates, and the full history elsewhere?

9

You could ignore the builtin history mechanism and abuse $PROMPT_COMMAND to write history any way you wanted. Some people keep a directory of history files, one for each shell/date/hostname, etc. Approximately something like this:

prompt_cmd() {
    echo "$_" >> $HOME/.my_history_file_$HOSTNAME
}

PROMPT_COMMAND=prompt_cmd

obviously embellish with dates, times, whatever...

  • Nice, concise :) – tink Mar 26 '13 at 22:45

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.