Improve the add-submodule script by making it so it doesn't need a second argument

This commit is contained in:
Kevin MacMartin 2024-03-03 22:20:11 -05:00
parent 4f47e36040
commit b063453342

View file

@ -1,6 +1,17 @@
#!/usr/bin/env bash #!/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 git submodule update --init --recursive