zsh: Autoload big functions

This commit is contained in:
2020-09-22 00:28:28 +02:00
parent 16896efa02
commit 0788926c8c
5 changed files with 155 additions and 143 deletions

View File

@@ -0,0 +1,31 @@
## Author: druckdev
## Created: 2020-09-13
##
## Completely remove a git submodule.
# Exit if not in git repo
local toplevel="$(git rev-parse --show-toplevel)" || return
# Exit if no arguements were given
[ $# -gt 0 ] || return
local separator=""
for arg in "$@"; do
printf "$separator"
# argument relative from git toplevel
local arg_from_git="${${arg:A}##$toplevel/}"
# argument has to exist
[ -e "$arg" ] || continue
# argument has to exist in repo
[ -e "$toplevel/$arg_from_git" ] || continue
# has to be a submodule
[ -e "$toplevel/.git/modules/$arg_from_git" ] || continue
git submodule deinit -f "$arg"
echo "command rm -rf \"$toplevel/.git/modules/$arg_from_git\""
command rm -rf "$toplevel/.git/modules/$arg_from_git"
git rm -f "$arg"
separator="\n"
done