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

Hello,
I recently learned how to show the modified time next to the file size using:

windo set viewcolumns=*{name}..,16{mtime},7{}

But I actually don't want to show mtime next to directories.
Is there a way to achieve this ?

Thanks a lot.

1 Answer

0 votes
by
selected by
 
Best answer

Hi.

There is no builtin switch for that, but you can use a Lua plugin like this:

local M = {}

local function fileMtime(info)
    local text = ''
    if info.entry.type ~= 'dir' then
        text = os.date(vifm.opts.global.timefmt, info.entry.mtime)
    end
    return { text = text }
end

local added = vifm.addcolumntype {
    name = 'FileMtime',
    handler = fileMtime
}
if not added then
    vifm.sb.error("Failed to add FileMtime view column")
end

return M

Then modify your command to be (mind that windo might not be necessary in vifmrc):

windo set viewcolumns=*{name}..,16{FileMtime},7{}

There is one defect though: it recognizes symbolic links to directories as files.

by

This seems to work.
However, it does not work on opening of vifm.
I need to go inside a directory and then back to see the time stamps on files.

by

Try adding plugin load above the set command. Normally plugins are loaded after vifmrc is parsed, which probably explains the issue.

by

Amazing, thank you so much!!

One last thing: I added this line in my config
autocmd DirEnter ~/Downloads setlocal sort=-mtime
which seems to break with the new change. How can I prevent the sort to change my viewcolumns ?

Normal:
normal

Downloads:
downloads

I also have set dirsize=nitems.

by

How can I prevent the sort to change my viewcolumns ?

Don't use {}, it's a special one which reflects the sorting. Use {size} explicitly:

windo set viewcolumns=*{name}..,16{FileMtime},7{size}
by

Thank you so much for everything ! :)

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.

Support Ukraine
...