Customizable statusline, df (#1168)
* opts statusline, df * renamed infostat -> ruler; removed os_lin, os_bsd * removed vscode --------- Co-authored-by: rr <rr@arveex.eu>
This commit is contained in:
1 parent
821b2fcd51
commit
eb84772032
8 files changed
+79
-1
No files matched your search
@@ -140,6 +140,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
incfilter bool (default false)
|
incfilter bool (default false)
|
||||||
incsearch bool (default false)
|
incsearch bool (default false)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
ruler []string (default '')
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
infotimefmtold string (default 'Jan _2 2006')
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
mouse bool (default false)
|
mouse bool (default false)
|
||||||
@@ -750,6 +751,11 @@ List of information shown for directory items at the right side of pane.
|
|||||||
Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
||||||
Information is only shown when the pane width is more than twice the width of information.
|
Information is only shown when the pane width is more than twice the width of information.
|
||||||
|
|
||||||
|
ruler []string (default 'acc:progress:selection:ind')
|
||||||
|
|
||||||
|
List of information shown in status line ruler.
|
||||||
|
Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
||||||
|
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
|
||||||
Format string of the file time shown in the info column when it matches this year.
|
Format string of the file time shown in the info column when it matches this year.
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
incfilter bool (default false)
|
incfilter bool (default false)
|
||||||
incsearch bool (default false)
|
incsearch bool (default false)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
ruler []string (default '')
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
infotimefmtold string (default 'Jan _2 2006')
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
mouse bool (default false)
|
mouse bool (default false)
|
||||||
@@ -794,6 +795,11 @@ Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
|||||||
Information is only shown when the pane width is more than twice the width of
|
Information is only shown when the pane width is more than twice the width of
|
||||||
information.
|
information.
|
||||||
|
|
||||||
|
ruler []string (default 'acc:progress:selection:ind')
|
||||||
|
|
||||||
|
List of information shown in status line ruler. Currently supported information
|
||||||
|
types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
||||||
|
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
|
||||||
Format string of the file time shown in the info column when it matches this
|
Format string of the file time shown in the info column when it matches this
|
||||||
|
|||||||
@@ -482,6 +482,21 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
gOpts.info = toks
|
gOpts.info = toks
|
||||||
|
case "ruler":
|
||||||
|
if e.val == "" {
|
||||||
|
gOpts.ruler = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toks := strings.Split(e.val, ":")
|
||||||
|
for _, s := range toks {
|
||||||
|
switch s {
|
||||||
|
case "df", "acc", "progress", "selection", "ind", "tot":
|
||||||
|
default:
|
||||||
|
app.ui.echoerr("ruler: should consist of 'df', 'acc', 'progress', 'selection', or 'ind' separated with colon")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gOpts.ruler = toks
|
||||||
case "infotimefmtnew":
|
case "infotimefmtnew":
|
||||||
gOpts.infotimefmtnew = e.val
|
gOpts.infotimefmtnew = e.val
|
||||||
case "infotimefmtold":
|
case "infotimefmtold":
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
incfilter bool (default false)
|
incfilter bool (default false)
|
||||||
incsearch bool (default false)
|
incsearch bool (default false)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
ruler []string (default '')
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
infotimefmtold string (default 'Jan _2 2006')
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
mouse bool (default false)
|
mouse bool (default false)
|
||||||
@@ -909,6 +910,12 @@ Apply filter pattern after each keystroke during filtering.
|
|||||||
.PP
|
.PP
|
||||||
List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information.
|
List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
ruler []string (default 'acc:progress:selection:ind')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
List of information shown in status line ruler. Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
.EE
|
.EE
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ var gOpts struct {
|
|||||||
hiddenfiles []string
|
hiddenfiles []string
|
||||||
history bool
|
history bool
|
||||||
info []string
|
info []string
|
||||||
|
ruler []string
|
||||||
shellopts []string
|
shellopts []string
|
||||||
keys map[string]expr
|
keys map[string]expr
|
||||||
cmdkeys map[string]expr
|
cmdkeys map[string]expr
|
||||||
@@ -132,6 +133,7 @@ func init() {
|
|||||||
gOpts.hiddenfiles = []string{".*"}
|
gOpts.hiddenfiles = []string{".*"}
|
||||||
gOpts.history = true
|
gOpts.history = true
|
||||||
gOpts.info = nil
|
gOpts.info = nil
|
||||||
|
gOpts.ruler = []string{"acc", "progress", "selection", "ind"}
|
||||||
gOpts.shellopts = nil
|
gOpts.shellopts = nil
|
||||||
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
||||||
gOpts.tempmarks = "'"
|
gOpts.tempmarks = "'"
|
||||||
|
|||||||
@@ -230,3 +230,14 @@ func exportFiles(f string, fs []string, pwd string) {
|
|||||||
os.Setenv("fx", envFiles)
|
os.Setenv("fx", envFiles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func diskFree(wd string) string {
|
||||||
|
var stat unix.Statfs_t
|
||||||
|
|
||||||
|
if err := unix.Statfs(wd, &stat); err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Available blocks * size per block = available space in bytes
|
||||||
|
return " df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize)))
|
||||||
|
}
|
||||||
@@ -184,3 +184,19 @@ func exportFiles(f string, fs []string, pwd string) {
|
|||||||
os.Setenv("fx", envFiles)
|
os.Setenv("fx", envFiles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func diskFree(wd string) string {
|
||||||
|
var free uint64
|
||||||
|
|
||||||
|
pathPtr, err := windows.UTF16PtrFromString(wd)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
err = windows.GetDiskFreeSpaceEx(pathPtr, &free, nil, nil) // cwd, free, total, available
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return " df: " + humanize(int64(free))
|
||||||
|
}
|
||||||
@@ -859,7 +859,22 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal)
|
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
ruler := fmt.Sprintf("%s%s%s %d/%d", acc, progress, selection, ind, tot)
|
ruler := ""
|
||||||
|
for _, s := range gOpts.ruler {
|
||||||
|
switch s {
|
||||||
|
case "df":
|
||||||
|
ruler = fmt.Sprintf("%s%s", ruler, diskFree(dir.path))
|
||||||
|
case "acc":
|
||||||
|
ruler = fmt.Sprintf("%s%s", ruler, acc)
|
||||||
|
case "progress":
|
||||||
|
ruler = fmt.Sprintf("%s%s", ruler, progress)
|
||||||
|
case "selection":
|
||||||
|
ruler = fmt.Sprintf("%s%s", ruler, selection)
|
||||||
|
case "ind":
|
||||||
|
ruler = fmt.Sprintf("%s %d/%d", ruler, ind, tot)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ui.msgWin.printRight(ui.screen, 0, st, ruler)
|
ui.msgWin.printRight(ui.screen, 0, st, ruler)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user