aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2013-04-29 14:24:36 +0200
committerMathias Bynens <mathias@qiwi.be>2013-04-29 14:24:36 +0200
commit71448f5fcd8bc86d86f1f770ed3397caa6d5a92e (patch)
treededc03ecd5a1bff9f786d6f3680e0df228e969a6
parent7356e3e74fafc8a90ea78b421b2df624bb432ab6 (diff)
downloaddotfiles-71448f5fcd8bc86d86f1f770ed3397caa6d5a92e.tar.gz
dotfiles-71448f5fcd8bc86d86f1f770ed3397caa6d5a92e.tar.bz2
dotfiles-71448f5fcd8bc86d86f1f770ed3397caa6d5a92e.zip
.functions: Add `targz`
`targz some-directory` creates `some-directory.tar.gz`, where compression is handled by either `zopfli` (if available) or `gzip`.
-rw-r--r--.functions14
1 files changed, 14 insertions, 0 deletions
diff --git a/.functions b/.functions
index 001e3d9..ef25746 100644
--- a/.functions
+++ b/.functions
@@ -26,6 +26,20 @@ function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}
+# Create a .tar.gz archive, using `zopfli` or `gzip` for compression
+function targz() {
+ if zopfli > /dev/null 2>&1; then
+ cmd="zopfli"
+ else
+ cmd="gzip"
+ fi
+ local tmpFile="${1}.tar"
+ tar -cvf "${tmpFile}" "${1}" &&
+ "${cmd}" "${tmpFile}" &&
+ rm "${tmpFile}" &&
+ echo "${tmpFile}.gz created successfully (compressed using \`${cmd}\`)."
+}
+
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then