diff options
author | Mathias Bynens <mathias@qiwi.be> | 2013-04-29 14:24:36 +0200 |
---|---|---|
committer | Mathias Bynens <mathias@qiwi.be> | 2013-04-29 14:24:36 +0200 |
commit | 71448f5fcd8bc86d86f1f770ed3397caa6d5a92e (patch) | |
tree | dedc03ecd5a1bff9f786d6f3680e0df228e969a6 | |
parent | 7356e3e74fafc8a90ea78b421b2df624bb432ab6 (diff) | |
download | dotfiles-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-- | .functions | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 |