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.
52 lines
1.4 KiB
52 lines
1.4 KiB
10 years ago
|
#
|
||
|
# firefox home profile (fhp) module to maintain the profile
|
||
|
# in a tmpfs or zram backed filesystem
|
||
|
#
|
||
10 years ago
|
# $Header: firefox-home-profile/functions/fhp Exp $
|
||
|
# $Aythor: (c) 2012-2015 -tclover <tokiclover@gmail.com> Exp $
|
||
10 years ago
|
# $License: MIT (or 2-clause/new/simplified BSD) Exp $
|
||
10 years ago
|
# $Version: 4.0 2015/05/05 Exp $
|
||
10 years ago
|
#
|
||
|
|
||
|
function die {
|
||
|
local ret=$?
|
||
10 years ago
|
print -P " %F{red}%1x: %F{yellow}%U%I%u:%f $argv" >&2
|
||
10 years ago
|
popd -q
|
||
10 years ago
|
return $ret
|
||
|
}
|
||
|
|
||
10 years ago
|
local dir compressor profile tarball
|
||
|
zstyle -s ':prezto:module:FHP' profile 'profile'
|
||
|
zstyle -s ':prezto:module:FHP' compressor 'compressor'
|
||
10 years ago
|
local ext=.tar.$compressor[(w)1]
|
||
|
|
||
10 years ago
|
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; }
|
||
10 years ago
|
}
|
||
10 years ago
|
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
|
||
10 years ago
|
}
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
#
|
||
|
# vim:fenc=utf-8:ft=zsh:ci:pi:sts=2:sw=2:ts=2:
|
||
|
#
|