mirror of
https://github.com/Crocmagnon/dotfiles.git
synced 2024-11-05 14:23:56 +01:00
12 lines
425 B
Fish
12 lines
425 B
Fish
function get_file_age -a file -d "Get the age of a file in seconds since it was last modified"
|
|
if test ! -e "$file"
|
|
return 1
|
|
end
|
|
|
|
if type -q perl
|
|
perl -e "printf(\"%s\n\", time - (stat ('$file'))[9])" ^ /dev/null
|
|
|
|
else if type -q python
|
|
python -c "from __future__ import print_function; import os, time; print(int(time.time() - os.path.getmtime('$file')))" ^ /dev/null
|
|
end
|
|
end
|