- Added alias functions to all bin scripts using first-letter pattern (e.g., `av` for `activate-venv`, `cwl` for `commit-with-llm`) - Implemented collision resolution by extending aliases with additional letters when conflicts occur or when shadowing standard shell commands - Documented alias implementation approach in library.md with complete alias map for reference - Verified shell syntax with `bash -n` and ensured proper argument passing with `"$@"` - Updated prompt frontmatter to reflect completed state and model used (infomaniak/moonshotai/Kimi-K2.6)
42 lines
1.6 KiB
Bash
Executable File
42 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
clone-git-folder() {
|
|
if [[ -z "$1" ]]; then
|
|
echo '$1/path is empty.'
|
|
exit
|
|
fi
|
|
|
|
local git_folders=$(ls-git-folder "$1")
|
|
for git_folder in $git_folders; do
|
|
git_folder="${git_folder#./}"
|
|
|
|
local git_folder_path=$(git config --file .gitmodules --get submodule."$git_folder".path)
|
|
local git_folder_url=$(git config --file .gitmodules --get submodule."$git_folder".url)
|
|
local shallow=$(git config --file .gitmodules --get submodule."$git_folder".shallow)
|
|
local git_folder_branch=$(git config --file .gitmodules --get submodule."$git_folder".branch)
|
|
|
|
if [[ -z "$git_folder_path" ]] || [[ -z "$git_folder_url" ]]; then
|
|
echo "Skipping: '$git_folder' not defined in .gitmodules."
|
|
continue
|
|
fi
|
|
|
|
# Skip if directory exists and is not empty
|
|
if [[ -d "$git_folder_path" ]] && [[ -n "$(ls -A "$git_folder_path")" ]]; then
|
|
echo "Skipping: '$git_folder_path' already exists and is not empty."
|
|
continue
|
|
fi
|
|
|
|
if [[ "$shallow" = "true" ]]; then
|
|
echo "Clone git folder $git_folder (shallow) with $git_folder_branch branch"
|
|
git -C "$git_folder" config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
|
git clone --depth 1 --no-single-branch "$git_folder_url" "$git_folder_path"
|
|
else
|
|
echo "Clone git folder $git_folder with $git_folder_branch branch"
|
|
git clone --branch="$git_folder_branch" "$git_folder_url" "$git_folder_path"
|
|
fi
|
|
done
|
|
}
|
|
cgif() {
|
|
clone-git-folder "$@"
|
|
}
|