mirror of
https://github.com/Crocmagnon/dotfiles.git
synced 2024-11-04 22:04:00 +01:00
13 lines
425 B
Fish
13 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
|