感谢@SharkIng 提醒,targz那个函数确实没有截全。
# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
function targz() {
local tmpFile="${@%/}.tar";
tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;
size=$(
stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat`
stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
);
local cmd="";
if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
# the .tar file is smaller than 50 MB and Zopfli is available; use it
cmd="zopfli";
else
if hash pigz 2> /dev/null; then
cmd="pigz";
else
cmd="gzip";
fi;
fi;
echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…";
"${cmd}" -v "${tmpFile}" || return 1;
[ -f "${tmpFile}" ] && rm "${tmpFile}";
zippedSize=$(
stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat`
stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
);
echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
}
1
zhuzhenyu 2017-06-08 19:36:58 +08:00
感谢分享
|
2
flaneurse 2017-06-08 20:45:04 +08:00 via Android
拿走了
|
3
gulangyu 2017-06-08 20:52:59 +08:00 via Android
感谢分享,已 Fork 😏
|
4
mrcode 2017-06-08 23:27:45 +08:00
|
5
zhx1991 2017-06-09 00:24:06 +08:00
我觉得用的最多的还是 zsh 里那套 git 的
什么 git add = ga git pull = gl git merge = gm git checkout = gco git checkout master = gcm 等等... |
6
skyblue 2017-06-09 09:48:50 +08:00
讲真, 要是有心分享,就别发截图,你还想让大伙 OCR 不成? 虽然我用不上...
|
7
wujunze 2017-06-09 10:26:40 +08:00
@skyblue #6 楼主发的有 repo 链接的 https://github.com/zhangchenchen/clean-dotfile/
|
8
hu6360567 2017-06-09 10:39:56 +08:00 via iPhone
cd 空格不比~好吗
|
9
SharkIng 2017-06-09 12:00:00 +08:00
你 targz 那个不全吧?
|
10
Jeremial 2017-06-09 13:12:59 +08:00
|
11
huangmingyou 2017-06-09 16:03:22 +08:00
够懒
|