summary refs log tree commit diff stats
path: root/user/settings/fish/functions/newest.fish
blob: 3f2fa66f9722cbfcbe6e5666acebf3f79953e88f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function newest
    if test (count $argv) -eq 0
        echo "Need at least one path"
        return 1
    end
    for arg in $argv
        if test -d $arg
            fd --hidden --print0 --max-depth 1 . $arg |
                bfs -files0-from - \( -name .git -prune \) -o \( -printf '%TY%Tm%Td%TH%TM %TF %h/%f\n' \) |
                sort --key 1nr,1 | head --lines 1 |
                cut -d ' ' -f 2,3
        end
    end
end