2014-09-25 21:38:22 +02:00
|
|
|
#
|
2015-05-14 20:06:24 +02:00
|
|
|
# $Header: browser-home-profile/functions/bhp Exp $
|
2015-05-10 16:23:21 +02:00
|
|
|
# $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> Exp $
|
2014-09-25 21:38:22 +02:00
|
|
|
# $License: MIT (or 2-clause/new/simplified BSD) Exp $
|
2015-05-14 20:06:24 +02:00
|
|
|
# $Version: 1.0 2015/05/14 Exp $
|
2014-09-25 21:38:22 +02:00
|
|
|
#
|
|
|
|
|
2015-05-14 20:06:24 +02:00
|
|
|
function bhp {
|
|
|
|
local PROFILE ext name=bhp profile tarball
|
|
|
|
zstyle -s ':prezto:module:BHP' PROFILE 'PROFILE'
|
|
|
|
zstyle -s ':prezto:module:BHP' compressor 'compressor'
|
|
|
|
ext=.tar.${compressor[(w)1]} profile=${PROFILE:t}
|
2014-09-25 21:38:22 +02:00
|
|
|
|
2015-05-14 20:06:24 +02:00
|
|
|
for dir (${HOME}/.${PROFILE} ${HOME}/.cache/${PROFILE#config/}) {
|
|
|
|
[[ -d ${dir} ]] || continue
|
2015-05-15 12:17:16 +02:00
|
|
|
pr-begin "Setting up tarball..."
|
2015-05-14 20:06:24 +02:00
|
|
|
pushd -q ${dir:h} || continue
|
2014-09-25 21:38:22 +02:00
|
|
|
|
2015-05-14 20:06:24 +02:00
|
|
|
if [[ -f ${profile}/.unpacked ]]; then
|
|
|
|
if [[ -f ${profile}${ext} ]] {
|
|
|
|
mv -f ${profile}${ext} ${profile}.old${ext} ||
|
2015-05-15 12:17:16 +02:00
|
|
|
{ pr-end 1 Moving; continue; }
|
2015-05-14 20:06:24 +02:00
|
|
|
}
|
|
|
|
tar -X ${profile}/.unpacked -Ocp ${profile} | \
|
|
|
|
${=compressor} ${profile}${ext} ||
|
2015-05-15 12:17:16 +02:00
|
|
|
{ pr-end 1 Packing; continue; }
|
2015-05-14 20:06:24 +02:00
|
|
|
else
|
|
|
|
if [[ -f ${profile}${ext} ]]; then
|
|
|
|
tarball=${profile}${ext}
|
|
|
|
elif [[ -f ${profile}.old${ext} ]]; then
|
|
|
|
tarball=${profile}.old${ext}
|
|
|
|
else
|
2015-05-15 12:17:16 +02:00
|
|
|
pr-warn "No tarball found."; continue
|
2015-05-14 20:06:24 +02:00
|
|
|
fi
|
|
|
|
${compressor[(w)1]} -cd ${tarball} | tar -xp &&
|
|
|
|
touch ${profile}/.unpacked ||
|
2015-05-15 12:17:16 +02:00
|
|
|
{ pr-end 1 Unpacking; continue; }
|
2015-05-14 20:06:24 +02:00
|
|
|
fi
|
2015-05-10 16:23:21 +02:00
|
|
|
popd -q
|
2015-05-15 12:17:16 +02:00
|
|
|
pr-end ${?}
|
2014-09-25 21:38:22 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-30 10:24:55 +02:00
|
|
|
|
2014-09-25 21:38:22 +02:00
|
|
|
#
|
|
|
|
# vim:fenc=utf-8:ft=zsh:ci:pi:sts=2:sw=2:ts=2:
|
|
|
|
#
|