Group history items together with timestamps on separate line (#3333 from floam/historyout)

This commit is contained in:
Aaron Gyes 2016-09-07 07:57:06 -07:00 committed by GitHub
commit 87fd9bca02
3 changed files with 5 additions and 5 deletions

View file

@ -34,7 +34,7 @@ The following options are available:
- `-p` or `--prefix` searches or deletes items in the history that begin with the specified text string. This is not currently supported by the `--delete` flag.
- `-t` or `--with-time` prefixes the output of each displayed history entry with the time it was recorded in the format "%Y-%m-%d %H:%M:%S" in your local timezone.
- `-t` or `--with-time` outputs the date and time ("%Y-%m-%d %H:%M:%S") history items were recorded at on a line starting with "#" before each history entry.
\subsection history-examples Example

View file

@ -1402,9 +1402,9 @@ static bool format_history_record(const history_item_t &item, const bool with_ti
const time_t seconds = item.timestamp();
struct tm timestamp;
if (!localtime_r(&seconds, &timestamp)) return false;
char timestamp_string[22];
if (strftime(timestamp_string, 22, "%Y-%m-%d %H:%M:%S ", &timestamp) != 21) return false;
streams.out.append(str2wcstring(timestamp_string));
wchar_t timestamp_string[24];
if (std::wcsftime(timestamp_string, 23, L"# %Y-%m-%d %H:%M:%S\n", &timestamp) == 0) return false;
streams.out.append(timestamp_string);
}
streams.out.append(item.str());
streams.out.append(L"\n");

View file

@ -78,7 +78,7 @@ expect_prompt -re {\r\necho start1.*\r\necho start2} {
# ==========
# Verify implicit searching with a request for timestamps includes the timestamps.
send "history -t echo start\r"
expect_prompt -re {\r\n\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d echo start1; builtin history;.*\r\n\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d echo start2; builtin history} {
expect_prompt -re {\r\n# \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\r\necho start1; builtin history;.*\r\n# \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\r\necho start2; builtin history} {
puts "history function implicit search with timestamps succeeded"
} unmatched {
puts stderr "history function implicit search with timestamps failed"