Skip to content

Commit 53f4f96

Browse files
authored
Merge pull request #33 from onihilist/fix/history
[WIP] - Corrective patch for history
2 parents 4b41e38 + 0a22c24 commit 53f4f96

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ chmod +x install.sh
4949

5050
---
5151

52+
### 🔧 Configuration file
53+
54+
The configuration file is available in the `.nshell` folder.
55+
And he is downloaded from here: https://gist.github.com/onihilist/8bf7548dc7478f1b6af2db4bdc0c668d
56+
57+
```json
58+
{
59+
"configuration": {
60+
"nshell": {
61+
"history": [
62+
{
63+
"expiration_time": "7d",
64+
"max_storage": 500
65+
}
66+
]
67+
}
68+
}
69+
}
70+
```
71+
72+
---
73+
5274
### 🎨 Custom themes
5375

5476
This is a little exemple of an custom theme.</br>

Shell/History/HistoryManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ public HistoryManager(string? path = null)
3030
private void Load()
3131
{
3232
if (File.Exists(_historyPath))
33+
{
3334
_history.AddRange(File.ReadAllLines(_historyPath));
35+
}
36+
else
37+
{
38+
File.Create(_historyPath).Close();
39+
}
3440
}
3541

3642
/// <summary>
@@ -51,6 +57,7 @@ public void Add(string command)
5157
{
5258
_history.Add(command);
5359
_currentIndex = _history.Count;
60+
File.WriteAllLines(_historyPath, _history);
5461
}
5562
}
5663

Shell/Readline/KeyAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private void MoveCursorWordRight()
300300

301301
private void HandleHistorySearch()
302302
{
303-
var search = new NShell.Shell.History.HistorySearch(_history);
303+
var search = new History.HistorySearch(_history);
304304
var result = search.Search(_initCursorPos4Console);
305305

306306
if (result != null)

0 commit comments

Comments
 (0)