# ╭────────────────────────────────────────────────────────────────────────────────────────────╮ # │ Define function gsa (to ask the user which submodule to clone to which path and which name │ # ╰────────────────────────────────────────────────────────────────────────────────────────────╯ set dir $PWD function gsa echo "-- these are the current submodules --" if command -v rg >/dev/null 2>&1 rg -i submodule (echo $dir/.gitmodules) end # ─< Prompt the user to enter the repository URL to add as a submodule >──────────────────── echo "-- enter the repository to add as a submodule --" read repo # ─< Prompt the user to enter the branch to checkout (e.g., main, master) >───────────────── echo "-- enter the branch to checkout (main/master..) --" read branch # ─< Prompt the user to enter the relative path where the submodule will be cloned >──────── # ─< Advise not to use the leading / or ./ >──────────────────────────────────────────────── echo "-- enter the relative path, where the submodule will be cloned to. (!! do it like this: ./path/to/clone/to) --" read -S path echo "-- enter a name for the submodule --" read -l name # ─< Ask the user for confirmation if the constructed command looks correct >─────────────── echo "git submodule add --branch $branch $repo $path" echo "-- does this command look right to you? [y/n] --" read -l comm # ─< Switch statement to handle the user's confirmation input >───────────────────────────── switch $comm # ─< If the user inputs 'y' or 'Y', execute the git submodule add command >───────────────── case 'y' 'Y' git submodule add --branch $branch --name $name $repo $path git submodule update --init --recursive git add . git commit -m "Addet $name as a submodule" git push # ─< If the user inputs 'n' or 'N', notify them to try again >────────────────────────────── case 'n' 'N' echo "-- all right, just try again :) --" end end