For some reason I get these odd line numbers or history numbers of some sort into my ~/.zsh_history
file like so:
: 1266694881:0;rake db:migrate
I'd rather not have to resort to regexing out the beginning, but I'd like my lines to be something like:
rake db:migrate
Does anyone have any suggestions for how to solve this? I've found setopt EXTENDED_HISTORY
but it doesn't seem to do much.
Try:
The numbers are the number of seconds since the Unix epoch of when the command began and the duration in seconds that the command ran.
Edit:
I forgot to mention that you should use the
fc
command to interact with history instead of parsing the history file. There are at least a couple of reasons for this. One is that the history file doesn't have the in-memory entries until you exit the shell, a threshold is met or you explicitly write it with thefc -AI
command (I believe). Secondly, you can leaveEXTENDED_HISTORY
turned on and still interact with the entries without having to remove that information. If it's off, then when you dofc -ld
, the shell uses the time that the shell started for the timestamp for commands in the history before that time. If it's off, it remembers the actual date and time (the numbers you're seeing in the file).See
man zshbuiltins
.List the most recent entries:
List them without command numbers:
List the most recent 20 commands without command numbers:
Include a timestamp and print only the most recent command:
Show all the commands (within the last 50) that include the string "setop" (shows
setopt
andunsetopt
):