mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
feat: retrieve next argument and assemble template
This commit is contained in:
parent
52ef4ad669
commit
48b36d5bb2
1 changed files with 25 additions and 17 deletions
|
|
@ -35,26 +35,34 @@ remove_flags() {
|
||||||
};
|
};
|
||||||
|
|
||||||
build_message () {
|
build_message () {
|
||||||
if [[ "$*" =~ (-sa|-as) ]]; then
|
local argv=("$@")
|
||||||
local attention='!'
|
local argc=${#@}
|
||||||
local scope="($2)"
|
local i=0
|
||||||
elif [[ "$1" =~ (-a|--attention) ]]; then
|
|
||||||
local attention='!'
|
|
||||||
elif [[ "$2" =~ (-a|--attention) ]]; then
|
|
||||||
local attention='!'
|
|
||||||
elif [[ "$*" =~ (-a|--attention) ]]; then
|
|
||||||
local attention='!'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$*" =~ (-s|--scope) ]]; then
|
while [ $i -lt $argc ];
|
||||||
local scope="($2)"
|
do
|
||||||
elif [[ "$2" =~ (-s|--scope) ]]; then
|
if [[ "${argv[$i]}" =~ (-sa|-as) ]]; then
|
||||||
local scope="($3)"
|
local attention='!'
|
||||||
fi
|
local scope="(${argv[$i + 1]})"
|
||||||
|
i=$[$i + 1]
|
||||||
|
fi
|
||||||
|
|
||||||
local message="'$type'${scope}$attention: $@";
|
if [[ "${argv[$i]}" =~ (-a|--attention) ]]; then
|
||||||
|
local attention='!'
|
||||||
|
i=$[$i + 1]
|
||||||
|
fi
|
||||||
|
|
||||||
git commit -m $(remove_flags "$message" "${_git_commit_flags[@]}")
|
if [[ "${argv[$i]}" =~ (-s|--scope) ]]; then
|
||||||
|
local scope="(${argv[$i + 1]})"
|
||||||
|
i=$[$i + 1]
|
||||||
|
fi
|
||||||
|
i=$[$i + 1]
|
||||||
|
done
|
||||||
|
|
||||||
|
local template="'$type'${scope}$attention: ${@}";
|
||||||
|
local message=$(remove_flags "$template" "${_git_commit_flags[@]}")
|
||||||
|
|
||||||
|
git commit -m "$message"
|
||||||
};
|
};
|
||||||
|
|
||||||
local alias type
|
local alias type
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue