Add Temporary Marks (#744)
* add temporary marks * change option format & documentation
This commit is contained in:
parent
18fb632efa
commit
958857f4c4
@ -157,6 +157,7 @@ var (
|
||||
"shellopts",
|
||||
"sortby",
|
||||
"timefmt",
|
||||
"tempmarks",
|
||||
"truncatechar",
|
||||
}
|
||||
)
|
||||
|
5
doc.go
5
doc.go
@ -137,6 +137,7 @@ The following options can be used to customize the behavior of lf:
|
||||
smartdia bool (default off)
|
||||
sortby string (default 'natural')
|
||||
tabstop int (default 8)
|
||||
tempmarks string (default '')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
truncatechar string (default '~')
|
||||
waitmsg string (default 'Press any key to continue')
|
||||
@ -708,6 +709,10 @@ Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', '
|
||||
|
||||
Number of space characters to show for horizontal tabulation (U+0009) character.
|
||||
|
||||
tempmarks string (default '')
|
||||
|
||||
A string that lists all marks to treat as temporary. They are not synced to other clients and are not saved in the bookmarks file. This option should be specified only in the global config file ("lfrc") as it may otherwise cause unintended side effects. Please note that the special bookmark "'" is always treated as temporary and does not need to be specified.
|
||||
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
|
||||
Format string of the file modification time shown in the bottom line.
|
||||
|
@ -141,6 +141,7 @@ The following options can be used to customize the behavior of lf:
|
||||
smartdia bool (default off)
|
||||
sortby string (default 'natural')
|
||||
tabstop int (default 8)
|
||||
tempmarks string (default '')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
truncatechar string (default '~')
|
||||
waitmsg string (default 'Press any key to continue')
|
||||
@ -756,6 +757,14 @@ Sort type for directories. Currently supported sort types are 'natural',
|
||||
Number of space characters to show for horizontal tabulation (U+0009)
|
||||
character.
|
||||
|
||||
tempmarks string (default '')
|
||||
|
||||
A string that lists all marks to treat as temporary. They are not synced to
|
||||
other clients and are not saved in the bookmarks file. This option should be
|
||||
specified only in the global config file ("lfrc") as it may otherwise cause
|
||||
unintended side effects. Please note that the special bookmark "'" is always
|
||||
treated as temporary and does not need to be specified.
|
||||
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
|
||||
Format string of the file modification time shown in the bottom line.
|
||||
|
6
eval.go
6
eval.go
@ -410,6 +410,12 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "tempmarks":
|
||||
if e.val != "" {
|
||||
gOpts.tempmarks = "'" + e.val
|
||||
} else {
|
||||
gOpts.tempmarks = "'"
|
||||
}
|
||||
case "timefmt":
|
||||
gOpts.timefmt = e.val
|
||||
case "truncatechar":
|
||||
|
7
lf.1
7
lf.1
@ -156,6 +156,7 @@ The following options can be used to customize the behavior of lf:
|
||||
smartdia bool (default off)
|
||||
sortby string (default 'natural')
|
||||
tabstop int (default 8)
|
||||
tempmarks string (default '')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
truncatechar string (default '~')
|
||||
waitmsg string (default 'Press any key to continue')
|
||||
@ -854,6 +855,12 @@ Sort type for directories. Currently supported sort types are 'natural', 'name',
|
||||
.PP
|
||||
Number of space characters to show for horizontal tabulation (U+0009) character.
|
||||
.PP
|
||||
.EX
|
||||
tempmarks string (default '')
|
||||
.EE
|
||||
.PP
|
||||
A string that lists all marks to treat as temporary. They are not synced to other clients and are not saved in the bookmarks file. This option should be specified only in the global config file ("lfrc") as it may otherwise cause unintended side effects. Please note that the special bookmark "'" is always treated as temporary and does not need to be specified.
|
||||
.PP
|
||||
.EX
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
.EE
|
||||
|
14
nav.go
14
nav.go
@ -1136,12 +1136,14 @@ func (nav *nav) sync() error {
|
||||
nav.saves[f] = cp
|
||||
}
|
||||
|
||||
path, ok := nav.marks["'"]
|
||||
oldmarks := nav.marks
|
||||
err = nav.readMarks()
|
||||
if ok {
|
||||
nav.marks["'"] = path
|
||||
for _, ch := range gOpts.tempmarks {
|
||||
tmp := string(ch)
|
||||
if v, e := oldmarks[tmp]; e {
|
||||
nav.marks[tmp] = v
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@ -1419,7 +1421,9 @@ func (nav *nav) writeMarks() error {
|
||||
|
||||
var keys []string
|
||||
for k := range nav.marks {
|
||||
keys = append(keys, k)
|
||||
if !strings.Contains(gOpts.tempmarks, k) {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
|
2
opts.go
2
opts.go
@ -71,6 +71,7 @@ var gOpts struct {
|
||||
cmdkeys map[string]expr
|
||||
cmds map[string]expr
|
||||
sortType sortType
|
||||
tempmarks string
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -114,6 +115,7 @@ func init() {
|
||||
gOpts.info = nil
|
||||
gOpts.shellopts = nil
|
||||
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
||||
gOpts.tempmarks = "'"
|
||||
|
||||
gOpts.keys = make(map[string]expr)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user