From 76d82b14cf56c198f0ad5ff34a9a895444ac9378 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Sun, 3 Mar 2024 22:20:32 -0500 Subject: [PATCH] Improve the add-submodule script by making it so it doesn't need a second argument --- add-submodule | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/add-submodule b/add-submodule index 1bd6e12..5fc22ee 100755 --- a/add-submodule +++ b/add-submodule @@ -1,6 +1,17 @@ #!/usr/bin/env bash -[[ -z "$2" ]] && exit 1 +# Exit if no argument has been provided +[[ -z "$1" ]] && exit 1 -git submodule add "$1" "vim/bundle/$2" +# Variables +url="$1" +name="${url/*\/}" + +# Exit if no name exists or the url and name variables are the same +[[ -z "$name" || "$url" = "$name" ]] && exit 1 + +# Add the submodule +git submodule add "$url" "vim/bundle/$name" || exit 1 + +# Initialize the submodule git submodule update --init --recursive