Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

as a long-term mc user i am trying to make a smoother transition by trying to set vifm so it looks very much like this file manager.

so far i've applied the following changes:

  • https://github.com/vifm/vifm-colors/blob/master/mc-like.vifm
    looks quite similar to the theme of the original mc
  • set viewcolumns=-{name},12{size},19{mtime}
    did not find a way how to tell vifm to format dates/times the way ls -l does that
  • set sizefmt=units:si,precision:3
    not exactly the same either
  • windo set timefmt=│%b\ %d\ %Y\ %H:%M│and set fillchars=vborder:│
    attempt to add bars to the output, it would be much better if viewcolumns supports custom characters in the format string

is there anything more i could do?

1 Answer

0 votes
by

did not find a way how to tell vifm to format dates/times the way ls -l does that

You mean when it prints either time or year? Didn't notice it before (and I use long-iso time format there either way). I don't think this can be done via 'timefmt', there is probably no sequence to do it.

set sizefmt=units:si,precision:3
not exactly the same either

For me mc just displays size in bytes.

it would be much better if viewcolumns supports custom characters in the format string

You want to do something like this?

viewcolumns=*{name}..,│,12{size},│,6{}.

is there anything more i could do?

If you're asking about something not mentioned above, then I don't know as I haven't used mc beyond doing a couple of primitive operations.

by

You mean when it prints either time or year?

it's useful in sense that old files stand out more + it saves you a few characters (that can be taken by longer filenames for instance)

For me mc just displays size in bytes.

i see bytes for files < approx. 400 kB, for bigger files i get K and M.

You want to do something like this?
viewcolumns=*{name}..,│,12{size},│,6{}.

yes, i'd like to be able to do exactly that.

by

it's useful in sense that old files stand out more + it saves you a few characters (that can be taken by longer filenames for instance)

Maybe we can introduce some extra macro which will be expanded in strftime() macros depending on the file.

i see bytes for files < approx. 400 kB, for bigger files i get K and M.

I think it works based on how wide size column is and starts using suffixes when size doesn't fit.

by

The 'viewcolumns' thing is finally there with a bit different syntax (this one allows specifying alignment and other fields):

set viewcolumns=*{name}..,{#│},12{size},{#│},6{}. 
by

wow, thank you! probably the closest to mc is:
set viewcolumns=*{name}..,{#│},11{size},{#│},18{mtime}.
and judging by the first impression size units actually works better in vifm than in mc!

by

Actually there was no change in how size is formatted, only in the ability to specify separators. User-defined view columns should be coming and custom size formatting might be implemented that way.

by

cool. is that what lua preparation is for?

by

Yes, custom columns, advanced custom :commands and alike.

by

See here for custom columns examples for size and time. Mind that by default plugins are loaded after vifmrc is processed so you have to do something like this:

plugin load

set viewcolumns+=8{MCSize}
by

thank you, is there a plugin how-to? i don't see those yet installed, or where the plugins belong in the structure of user files. the documentation only mentions plugin for vim (for opening a file using vifm).

by
by

Thank you, this is even closer! However there's a bit of inaccuracy in LsTime. The definition is more like.. display year (instead of time) if the more than a year (365d) has passed. So I get a time for a date in 2020 even if we have 2021:
$ date; ls -ld system-connections Sat Mar 20 23:09:48 CET 2021 drwx------ 2 root root 4096 Nov 29 14:35 system-connections
vifm currently shows nov 29 2020.

by

Here's an updated function:

local secsPerYear = 365*24*60*60
local function lsTime(info)
    local time = info.entry.mtime
    local ageYears = os.difftime(os.time(), time)//secsPerYear
    if ageYears == 0 then
        return os.date('%b %d %H:%M', time)
    else
        return os.date('%b %d  %Y', time)
    end
end
by

Thank you, that worked nicely!

...