While working on fixing other problems with the history command it occurred to me that there really should be a flag to limit the number of search results to the n most recent commands. I was used to having such a capability when I used zsh and wrote my own history wrapper function when I switched to fish in order to have a similar capability. This would be similar to git log -nnn and far more efficient than piping the output of history -search through head -nnn or directly iterating over $history in a fish function.
The text was updated successfully, but these errors were encountered:
How would you get the timestamp; e.g., history -t, with your example using string? And, as you noted, piping the output through head or tail is slow and doesn't correctly handle multiline commands. Also, slicing isn't as simple as you suggest given the current behavior that a slice endpoint must be a valid index. So if you fewer than 500 entries that fails. 95% of time time I just want to see the recent history to jog my memory.
How would you get the timestamp; e.g., history -t, with your example using string?
We don't currently expose the timestamp through the $history interface - so I don't think I could. This isn't related to the speed of history, just something we don't do yet that we ought to figure out.
I suppose we could provide another magic array. [timestamp1, timestamp2... ] seems pleasant enough but if someone finds an item in $history and tries to look it up in $historyplus interactively they're asking for pain.
So you'd want to have this array have the same entries it does now but also provide the timestamps. This seems nice:
make install fish #7/15/2015 4:45PM
I was actually considering assembling just that after the fact just in history.fish for the output that we run through the pager now, because it moved the timestamp away from the left side, was easier to find with a regex, made the lines able to run through eval/fish -n directly, and I thought it would be nice if for display purposes the output could entirely be ran through fish_indent --ansi to syntax highlight them, especially with the comment coloring being not bad at all for the timestamp display.