From a75bf0a1d17151ea96d674b80294bfe57a00aef6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?=
 <marcodiegomesquita@gmail.com>
Date: Thu, 14 Sep 2017 20:02:24 -0300
Subject: [PATCH] history: remember the list of executed commands across
 sessions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
---
 src/files.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/files.c b/src/files.c
index aa2ceab2..d53c794a 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2828,8 +2828,11 @@ void load_history(void)
 		/* Encode any embedded NUL as 0x0A. */
 		unsunder(line, read);
 		update_history(history, line);
-	    } else
+	    } else if (history == &search_history)
 		history = &replace_history;
+	   else
+		history = &execute_history;
+
 	}
 
 	fclose(hist);
@@ -2871,7 +2874,7 @@ void save_history(void)
 
     /* If the histories are unchanged or empty, don't bother saving them. */
     if (!history_has_changed() || (searchbot->lineno == 1 &&
-				replacebot->lineno == 1))
+		replacebot->lineno == 1 && executebot->lineno == 1))
 	return;
 
     searchhist = histfilename();
@@ -2888,7 +2891,8 @@ void save_history(void)
 	/* Don't allow others to read or write the history file. */
 	chmod(searchhist, S_IRUSR | S_IWUSR);
 
-	if (!writehist(hist, searchage) || !writehist(hist, replaceage))
+	if (!writehist(hist, searchage) || !writehist(hist, replaceage) ||
+				!writehist(hist, executetop))
 	    fprintf(stderr, _("Error writing %s: %s\n"), searchhist,
 			strerror(errno));
 
-- 
GitLab