Add xstat func to get real creation time

This commit is contained in:
Jeremy Gardais 2021-08-09 10:01:58 +02:00
parent 815ad39809
commit f72e008f94
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 11 additions and 0 deletions

11
zshrc
View File

@ -1383,6 +1383,17 @@ v() {
fi fi
} }
# Try to give the real creation time of a file
xstat() {
for target in "${@}"; do
inode=$(ls -di "${target}" | cut -d ' ' -f 1)
fs=$(df "${target}" | tail -1 | awk '{print $1}')
crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null |
grep -oP 'crtime.*--\s*\K.*')
printf "%s\t%s\n" "${crtime}" "${target}"
done
}
# PDF with fzf {{{ # PDF with fzf {{{
# pdf - fuzzy open with "${PDF_VIEWER}" from current directory # pdf - fuzzy open with "${PDF_VIEWER}" from current directory
# cd into the directory of the selected file # cd into the directory of the selected file