Skip to content

Commit 5b3c841

Browse files
heitorPBmathiasbynens
authored andcommitted
.functions: Add file size output to targz
Closes mathiasbynens#670.
1 parent ef819d5 commit 5b3c841

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.functions

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function targz() {
3535

3636
size=$(
3737
stat -f"%z" "${tmpFile}" 2> /dev/null; # OS X `stat`
38-
stat -c"%s" "${tmpFile}" 2> /dev/null # GNU `stat`
38+
stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
3939
);
4040

4141
local cmd="";
@@ -50,10 +50,16 @@ function targz() {
5050
fi;
5151
fi;
5252

53-
echo "Compressing .tar using \`${cmd}\`";
53+
echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`";
5454
"${cmd}" -v "${tmpFile}" || return 1;
5555
[ -f "${tmpFile}" ] && rm "${tmpFile}";
56-
echo "${tmpFile}.gz created successfully.";
56+
57+
zippedSize=$(
58+
stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # OS X `stat`
59+
stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
60+
);
61+
62+
echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
5763
}
5864

5965
# Determine size of a file or total size of a directory

0 commit comments

Comments
 (0)