Skip to content

Upgrading history on Unix Systems

On unix systems, like Linux and MacOS, all commands are logged by default in order in which they were input. These logs can be accessed using the history command. To see the time they were logged you can just use arguments such as -i or -E as displayed below, or you can permanently set an environment variable to include the date when you run history

history -i
history -E

# Only works for bash, for zsh you will need an alias
HISTTIMEFORMAT="%F %T "

# .bashrc
echo "export HISTTIMEFORMAT=\"%F %T \"" >> ~/.bashrc 
source ~/.bashrc 

# .zshrc
echo "export HISTTIMEFORMAT=\"%F %T \"" >> ~/.zshrc 
source ~/.zshrc 

Sources