From b339e5cee84ace073ca80d3d8321b681c58f850d Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Wed, 3 Apr 2019 09:07:50 +0530 Subject: [PATCH] vifm.mkd: most recently committed files! --- vifm.mkd | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/vifm.mkd b/vifm.mkd index fc13b4b..236e323 100644 --- a/vifm.mkd +++ b/vifm.mkd @@ -85,11 +85,20 @@ the author's own vifmrc!) * **custom views** (as vifm calls them) allow you to load a filelist generated by a program. I've *always* struggled with tasks like finding - the most recent 10 files, the largest 20 files, or whatever, because I - always had to get out of the file manager. + the most recent files, most recently committed files, largest files, or + whatever, because I always had to get out of the file manager. Not anymore! See section on "finding files" later. + A quick note about the "most recently committed files": by itself that's + not such a big deal, but, combined with the previous feature ("git log" as + preview), it is a good contrast to `gitk` (or `:GV` in vim) -- it is a + view from the other direction, in a way (files -> commits, as opposed to + commits -> files). Time will tell how useful it really is, but I can + certainly say that I know of no other file manager that lets me do this at + all, leave alone so painlessly and intuitively, and that's the important + part here. + * **sorting display**: whatever field you choose to sort by, that is the field you will see next to the filename! @@ -412,17 +421,21 @@ view. ### finding the latest, or largest, files -I mentioned this up at the top, but here's how you get the largest N or newest -N files. +I mentioned this up at the top, but here's how you get the largest N, newest +N, or most recently committed N, files. - command! xm :set viewcolumns=*{name}..,24{mtime}| InternalXM %a - command! xs :set viewcolumns=*{name}..,8{size}| InternalXS %a - command! InternalXM find -type f -print0 | xargs -0 ls -tr | tail -%a | tac %U - command! InternalXS find -type f -print0 | xargs -0 ls -Sr | tail -%a | tac %U + command! xc :set viewcolumns=*{name}..,24{mtime}| zzzInternalXC %a + command! xm :set viewcolumns=*{name}..,24{mtime}| zzzInternalXM %a + command! xs :set viewcolumns=*{name}..,8{size}| zzzInternalXS %a + command! zzzInternalXC git log --name-only --format=%%n | perl -lne 'print if /./ and -f and not $seen{$_}++' | head -%a %U + command! zzzInternalXM find -type f -print0 | xargs -0 ls -tr | tail -%a | tac %U + command! zzzInternalXS find -type f -print0 | xargs -0 ls -Sr | tail -%a | tac %U + " the 'zzz' is so they will show up last when I hit ':' + " also, notice the %% in the format paramater in zzzInternalXC -You run this by typing `:xs 10` to get the largest 10 files (s for 'size'), -or, say, `:xm 20` to get the newest 20 files (m for 'mtime'), and they will be -loaded in a **custom view**. +You run this by typing `:xc 10` to get the 10 most recently committed files (c +for 'commit'), and they will be loaded in a **custom view**. Similarly s is +for size and m is for mtime. The [`%a`][pc_a] is replaced by the 10 or 20 or whatever you supplied. However, the [`%U`][pc_U] is what makes all this work: it basically takes the @@ -430,11 +443,6 @@ command output and creates a "custom view" out of it! (I use `%U` instead of `%u` because I don't want vifm to needlessly sort it on some other key, when it's already sorted!) -You can make some adjustments to the options supplied to `ls` if you want, -say, *oldest* files, or *smallest* files etc. (Do not be tempted to convert -the `tail` to a `head`; that often results in a pipe error. Not harmful but -ugly and disconcerting.) - [sf]:https://github.com/sitaramc/active-aliases/blob/master/examples/sf "https://github.com/sitaramc/active-aliases/blob/master/examples/sf" [fprg]:https://vifm.info/vimdoc.shtml#vifm-%27findprg%27 "https://vifm.info/vimdoc.shtml#vifm-%27findprg%27" [lprg]:https://vifm.info/vimdoc.shtml#vifm-%27locateprg%27 "https://vifm.info/vimdoc.shtml#vifm-%27locateprg%27"