Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to read the timestamp of Zsh history

Tags:

timestamp

zsh

Problem: to understand the following timestamp

1241036430

at ~/.history

: 1241036336:0;vim ~/.zshrc
: 1241036379:0;vim ~/bin/HideTopBar
: 1241036421:0;ls
: 1241036430:0;cat ~/.history

when I have

setopt EXTENDED_HISTORY
HISTFILE=~/.history

in .zshrc.

How can you read the timestamp?

like image 961
Léo Léopold Hertz 준영 Avatar asked Apr 29 '09 20:04

Léo Léopold Hertz 준영


2 Answers

Try history -d. Or just type history - and press control-D to get all the various options:

% history -
-D  -- print elapsed times
-E  -- dd.mm.yyyy format time-stamps
-d  -- print time-stamps
-f  -- mm/dd/yyyy format time-stamps
-i  -- yyyy-mm-dd format time-stamps
-m  -- treat first argument as a pattern
-n  -- suppress line numbers
-r  -- reverse order of the commands
like image 133
Nicholas Riley Avatar answered Oct 14 '22 03:10

Nicholas Riley


You can display the whole history with human-readable timestamps using this one-liner taken from an answer on the zsh mailing list:

perl -lne 'm#: (\d+):\d+;(.+)# && printf "%s :: %s\n",scalar localtime $1,$2' $HISTFILE

I would recommend piping the output to a pager (less for example) to make it more readable.

like image 34
Timothée Ravier Avatar answered Oct 14 '22 04:10

Timothée Ravier