You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
oh-my-fish/pkg/omf/functions/packages/omf.packages.remove.fish

52 lines
1.1 KiB
Fish

function omf.packages.remove -a pkg
if not omf.packages.valid_name $pkg
echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) >&2
return $OMF_INVALID_ARG
end
if test $pkg = "omf" -o $pkg = "default"
echo (omf::err)"You can't remove `$pkg`"(omf::off) >&2
return $OMF_INVALID_ARG
end
for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$pkg
test -d $path;
and set found;
or continue
# Run uninstall hook first.
omf.packages.run_hook $path uninstall
if test -f $path/uninstall.fish
source $path/uninstall.fish 2> /dev/null
end
emit uninstall_$pkg
emit {$pkg}_uninstall
if command rm -rf $path
omf.bundle.remove "package" $pkg
return 0
else
return 1
end
end
for path in {$OMF_PATH,$OMF_CONFIG}/themes/$pkg
test -d $path;
and set found;
or continue
test $pkg = (cat $OMF_CONFIG/theme);
and echo default > $OMF_CONFIG/theme
if command rm -rf $path
omf.bundle.remove "theme" $pkg
return 0
else
return 1
end
end
set -q found; or return 2
end