1
0
Fork 0

browser-home-profile/functions/bhp: Converted specific browser to generic browser profile

pull/890/head
tokiclover 10 years ago
parent 2069e408fb
commit 8fa34532c2

@ -1,48 +1,43 @@
# #
# firefox home profile (fhp) module to maintain the profile # $Header: browser-home-profile/functions/bhp Exp $
# in a tmpfs or zram backed filesystem
#
# $Header: firefox-home-profile/functions/fhp Exp $
# $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> Exp $ # $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> Exp $
# $License: MIT (or 2-clause/new/simplified BSD) Exp $ # $License: MIT (or 2-clause/new/simplified BSD) Exp $
# $Version: 4.0 2015/05/05 Exp $ # $Version: 1.0 2015/05/14 Exp $
# #
function die { function bhp {
local ret=$? local PROFILE ext name=bhp profile tarball
print -P " %F{red}%1x: %F{yellow}%U%I%u:%f $argv" >&2 zstyle -s ':prezto:module:BHP' PROFILE 'PROFILE'
popd -q zstyle -s ':prezto:module:BHP' compressor 'compressor'
return $ret ext=.tar.${compressor[(w)1]} profile=${PROFILE:t}
}
local dir compressor profile tarball for dir (${HOME}/.${PROFILE} ${HOME}/.cache/${PROFILE#config/}) {
zstyle -s ':prezto:module:FHP' profile 'profile' [[ -d ${dir} ]] || continue
zstyle -s ':prezto:module:FHP' compressor 'compressor' pr_begin "Setting up tarball..."
local ext=.tar.$compressor[(w)1] pushd -q ${dir:h} || continue
for dir ("$HOME"/.{,cache/}mozilla/firefox) { if [[ -f ${profile}/.unpacked ]]; then
pushd -q "$dir" || continue if [[ -f ${profile}${ext} ]] {
if [[ -f $profile/.unpacked ]] { mv -f ${profile}${ext} ${profile}.old${ext} ||
if [[ -f $profile$ext ]] { { pr_end 1 Moving; continue; }
mv -f $profile{,.old}$ext || }
{ die "Failed to override the old tarball"; continue; } tar -X ${profile}/.unpacked -Ocp ${profile} | \
} ${=compressor} ${profile}${ext} ||
tar -X $profile/.unpacked -Ocp $profile | $=compressor $profile$ext || { pr_end 1 Packing; continue; }
die "Failed to repack a new tarball" else
popd -q if [[ -f ${profile}${ext} ]]; then
} else { tarball=${profile}${ext}
compressor=$compressor[(w)1] elif [[ -f ${profile}.old${ext} ]]; then
if [[ -f $profile$ext ]] { tarball=${profile}.old${ext}
tarball=$profile$ext else
} elif [[ -f $profile.old$ext ]] { pr_warn "No tarball found."; continue
tarball=$profile.old$ext fi
} else { ${compressor[(w)1]} -cd ${tarball} | tar -xp &&
die "No tarball found" touch ${profile}/.unpacked ||
continue { pr_end 1 Unpacking; continue; }
} fi
$compressor -cd $tarball | tar -xp && touch $profile/.unpacked ||
die "Failed to unpack profile tarball"
popd -q popd -q
pr_end ${?}
} }
} }

Loading…
Cancel
Save