From 33abd461cc8140b928f2ed1f533e6f1009f65182 Mon Sep 17 00:00:00 2001 From: onihilist Date: Wed, 19 Nov 2025 14:01:46 +0100 Subject: [PATCH 1/2] fix: create .nhistory file when HistoryManager is init --- README.md | 22 ++++++++++++++++++++++ Shell/History/HistoryManager.cs | 7 +++++++ Shell/Readline/KeyAction.cs | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3366a04..7cd11c6 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,28 @@ chmod +x install.sh --- +### 🔧 Configuration file + +The configuration file is available in the `.nshell` folder. +And he is downloaded from here: https://gist.github.com/onihilist/8bf7548dc7478f1b6af2db4bdc0c668d + +```json +{ + "configuration": { + "nshell": { + "history": [ + { + "expiration_time": "7d", + "max_storage": 500 + } + ] + } + } +} +``` + +--- + ### 🎨 Custom themes This is a little exemple of an custom theme.
diff --git a/Shell/History/HistoryManager.cs b/Shell/History/HistoryManager.cs index 02ec1cb..81ed36a 100644 --- a/Shell/History/HistoryManager.cs +++ b/Shell/History/HistoryManager.cs @@ -30,7 +30,14 @@ public HistoryManager(string? path = null) private void Load() { if (File.Exists(_historyPath)) + { _history.AddRange(File.ReadAllLines(_historyPath)); + } + else + { + File.Create(_historyPath).Close(); + _history.AddRange(File.ReadAllLines(_historyPath)); + } } /// diff --git a/Shell/Readline/KeyAction.cs b/Shell/Readline/KeyAction.cs index 9cd2c1c..6d886ac 100644 --- a/Shell/Readline/KeyAction.cs +++ b/Shell/Readline/KeyAction.cs @@ -300,7 +300,7 @@ private void MoveCursorWordRight() private void HandleHistorySearch() { - var search = new NShell.Shell.History.HistorySearch(_history); + var search = new History.HistorySearch(_history); var result = search.Search(_initCursorPos4Console); if (result != null) From 0a22c24c451b522da136da3905066f9c21e354a8 Mon Sep 17 00:00:00 2001 From: onihilist Date: Mon, 8 Dec 2025 10:52:36 +0100 Subject: [PATCH 2/2] fix: write into the history file --- Shell/History/HistoryManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shell/History/HistoryManager.cs b/Shell/History/HistoryManager.cs index 81ed36a..a7bbbfc 100644 --- a/Shell/History/HistoryManager.cs +++ b/Shell/History/HistoryManager.cs @@ -36,7 +36,6 @@ private void Load() else { File.Create(_historyPath).Close(); - _history.AddRange(File.ReadAllLines(_historyPath)); } } @@ -58,6 +57,7 @@ public void Add(string command) { _history.Add(command); _currentIndex = _history.Count; + File.WriteAllLines(_historyPath, _history); } }