1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
prezto/modules/firefox-home-profile/functions/fhp

52 lines
1.4 KiB

#
# firefox home profile (fhp) module to maintain the profile
# in a tmpfs or zram backed filesystem
#
# $Header: firefox-home-profile/functions/fhp Exp $
# $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> Exp $
# $License: MIT (or 2-clause/new/simplified BSD) Exp $
# $Version: 4.0 2015/05/05 Exp $
#
function die {
local ret=$?
print -P " %F{red}%1x: %F{yellow}%U%I%u:%f $argv" >&2
popd -q
return $ret
}
local dir compressor profile tarball
zstyle -s ':prezto:module:FHP' profile 'profile'
zstyle -s ':prezto:module:FHP' compressor 'compressor'
local ext=.tar.$compressor[(w)1]
for dir ("$HOME"/.{,cache/}mozilla/firefox) {
pushd -q "$dir" || continue
if [[ -f $profile/.unpacked ]] {
if [[ -f $profile$ext ]] {
mv -f $profile{,.old}$ext ||
{ die "Failed to override the old tarball"; continue; }
}
tar -X $profile/.unpacked -Ocp $profile | $=compressor $profile$ext ||
die "Failed to repack a new tarball"
popd -q
} else {
compressor=$compressor[(w)1]
if [[ -f $profile$ext ]] {
tarball=$profile$ext
} elif [[ -f $profile.old$ext ]] {
tarball=$profile.old$ext
} else {
die "No tarball found"
continue
}
$compressor -cd $tarball | tar -xp && touch $profile/.unpacked ||
die "Failed to unpack profile tarball"
popd -q
}
}
#
# vim:fenc=utf-8:ft=zsh:ci:pi:sts=2:sw=2:ts=2:
#