From da2d8a297963b80e4da7367bcada18df054b850c Mon Sep 17 00:00:00 2001 From: segf00lt <74469650+segf00lt@users.noreply.github.com> Date: Sun, 10 Jul 2022 09:32:34 -0300 Subject: [PATCH] added history options (#866) * added history options * sorry forgot to update docs --- app.go | 6 ++++-- doc.go | 1 + docstring.go | 1 + eval.go | 6 ++++++ lf.1 | 1 + opts.go | 2 ++ 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app.go b/app.go index 5ef53f34..5ccab801 100644 --- a/app.go +++ b/app.go @@ -59,8 +59,10 @@ func newApp(ui *ui, nav *nav) *app { } func (app *app) quit() { - if err := app.writeHistory(); err != nil { - log.Printf("writing history file: %s", err) + if gOpts.history { + if err := app.writeHistory(); err != nil { + log.Printf("writing history file: %s", err) + } } if !gSingleMode { if err := remote(fmt.Sprintf("drop %d", gClientID)); err != nil { diff --git a/doc.go b/doc.go index 1704fcb3..de23905b 100644 --- a/doc.go +++ b/doc.go @@ -124,6 +124,7 @@ The following options can be used to customize the behavior of lf: globsearch bool (default off) hidden bool (default off) hiddenfiles []string (default '.*') + history bool (default on) icons bool (default off) ifs string (default '') ignorecase bool (default on) diff --git a/docstring.go b/docstring.go index c5c538b8..e0ddf7ff 100644 --- a/docstring.go +++ b/docstring.go @@ -128,6 +128,7 @@ The following options can be used to customize the behavior of lf: globsearch bool (default off) hidden bool (default off) hiddenfiles []string (default '.*') + history bool (default on) icons bool (default off) ifs string (default '') ignorecase bool (default on) diff --git a/eval.go b/eval.go index 53191b46..af3671d1 100644 --- a/eval.go +++ b/eval.go @@ -125,6 +125,12 @@ func (e *setExpr) eval(app *app, args []string) { app.nav.position() app.ui.sort() app.ui.loadFile(app.nav, true) + case "history": + gOpts.history = true + case "nohistory": + gOpts.history = false + case "history!": + gOpts.history = !gOpts.history case "icons": gOpts.icons = true case "noicons": diff --git a/lf.1 b/lf.1 index f0a7311c..cf767a0f 100644 --- a/lf.1 +++ b/lf.1 @@ -143,6 +143,7 @@ The following options can be used to customize the behavior of lf: globsearch bool (default off) hidden bool (default off) hiddenfiles []string (default '.*') + history bool (default on) icons bool (default off) ifs string (default '') ignorecase bool (default on) diff --git a/opts.go b/opts.go index 2909809f..3b7121e2 100644 --- a/opts.go +++ b/opts.go @@ -67,6 +67,7 @@ var gOpts struct { truncatechar string ratios []int hiddenfiles []string + history bool info []string shellopts []string keys map[string]expr @@ -117,6 +118,7 @@ func init() { gOpts.truncatechar = "~" gOpts.ratios = []int{1, 2, 3} gOpts.hiddenfiles = []string{".*"} + gOpts.history = true gOpts.info = nil gOpts.shellopts = nil gOpts.sortType = sortType{naturalSort, dirfirstSort}