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