Is there a way to have in the .bash_history file, listed: the directory where the command has been typed, the date, and the command ?
Ubuntu – History command showing the directory and the date
history
history
Is there a way to have in the .bash_history file, listed: the directory where the command has been typed, the date, and the command ?
Best Answer
History command showing the directory: NO! :(
History command showing the date: YES! :)
That's because (from
man history
):So, nothing about the directory where the command has been typed.
To know the exact time certain command was executed, see
help history
:So all you have to do is to set
$HISTTIMEFORMAT
something like this in the current shell:To have it permanently set, run the following command:
The above command will add a new line (
export HISTTIMEFORMAT="%F %T "
) at the end of your~/.bashrc
file.Now, the output of
history
will look something like this: