diff --git a/doc.go b/doc.go index 1e44629f..d447be3e 100644 --- a/doc.go +++ b/doc.go @@ -140,6 +140,7 @@ The following options can be used to customize the behavior of lf: incfilter bool (default false) incsearch bool (default false) info []string (default '') + ruler []string (default '') infotimefmtnew string (default 'Jan _2 15:04') infotimefmtold string (default 'Jan _2 2006') 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'. 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') Format string of the file time shown in the info column when it matches this year. diff --git a/docstring.go b/docstring.go index ef416d90..3c45458b 100644 --- a/docstring.go +++ b/docstring.go @@ -143,6 +143,7 @@ The following options can be used to customize the behavior of lf: incfilter bool (default false) incsearch bool (default false) info []string (default '') + ruler []string (default '') infotimefmtnew string (default 'Jan _2 15:04') infotimefmtold string (default 'Jan _2 2006') 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. + 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') Format string of the file time shown in the info column when it matches this diff --git a/eval.go b/eval.go index 9c553344..d97173be 100644 --- a/eval.go +++ b/eval.go @@ -482,6 +482,21 @@ func (e *setExpr) eval(app *app, args []string) { } } 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": gOpts.infotimefmtnew = e.val case "infotimefmtold": diff --git a/lf.1 b/lf.1 index a0a2c451..27188242 100644 --- a/lf.1 +++ b/lf.1 @@ -159,6 +159,7 @@ The following options can be used to customize the behavior of lf: incfilter bool (default false) incsearch bool (default false) info []string (default '') + ruler []string (default '') infotimefmtnew string (default 'Jan _2 15:04') infotimefmtold string (default 'Jan _2 2006') mouse bool (default false) @@ -909,6 +910,12 @@ Apply filter pattern after each keystroke during filtering. .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. .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 infotimefmtnew string (default 'Jan _2 15:04') .EE diff --git a/opts.go b/opts.go index 48324be3..c4a17681 100644 --- a/opts.go +++ b/opts.go @@ -74,6 +74,7 @@ var gOpts struct { hiddenfiles []string history bool info []string + ruler []string shellopts []string keys map[string]expr cmdkeys map[string]expr @@ -132,6 +133,7 @@ func init() { gOpts.hiddenfiles = []string{".*"} gOpts.history = true gOpts.info = nil + gOpts.ruler = []string{"acc", "progress", "selection", "ind"} gOpts.shellopts = nil gOpts.sortType = sortType{naturalSort, dirfirstSort} gOpts.tempmarks = "'" diff --git a/os.go b/os.go index a0ae9fda..bfbbb58f 100644 --- a/os.go +++ b/os.go @@ -230,3 +230,14 @@ func exportFiles(f string, fs []string, pwd string) { 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))) +} diff --git a/os_windows.go b/os_windows.go index 2dca3376..faff5355 100644 --- a/os_windows.go +++ b/os_windows.go @@ -184,3 +184,19 @@ func exportFiles(f string, fs []string, pwd string) { 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)) +} diff --git a/ui.go b/ui.go index 86578499..e6a71e84 100644 --- a/ui.go +++ b/ui.go @@ -859,7 +859,22 @@ func (ui *ui) drawStatLine(nav *nav) { 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) }