Show the first few history entries in set | grep history

As before, but do so efficiently. See #6290
This commit is contained in:
Johannes Altmanninger
2019-12-29 17:43:05 +01:00
parent d0edd984d5
commit 3d9c0d3c69
5 changed files with 29 additions and 8 deletions

View File

@@ -482,8 +482,12 @@ static int builtin_set_list(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
if (!names_only) {
wcstring val;
if (key == L"history") {
val = history_variable_description;
if (opts.shorten_ok && key == L"history") {
history_t *history = &history_t::history_with_name(history_session_id(env_stack_t::principal()));
for (size_t i = 1; i < history->size() && val.size() < 64; i++) {
if (i > 1) val += L' ';
val += expand_escape_string(history->item_at_index(i).str());
}
} else {
auto var = parser.vars().get(key, compute_scope(opts));
if (!var.missing_or_empty()) {