cat | tee -a ~/.bashrc > /dev/null << "EOF"
# supported cases:
# git config user.email
# git clone https://aaa.git bbb && ls -al ~/.gitconfig
# git clone https://aaa.git aaa
# git checkout -b test
# git commit -am 'issue-42"s '
# git commit -am "issue-42's "
# git commit -am "issue-42 Mark's"' "pears"'
# git branch --set-upstream-to=origin/test test
# git pull
# git push -u origin test
# git push --set-upstream origin test
function git() {
COMM=
for i in "${@:2}"; do
arg=$(echo -e $i | sed -r "s/'/\\\'/g")
COMM="$COMM $'$arg'"
done
echo "Typed command: $COMM"
if [[ "$1" == "clone" || "$1" == "push" || "$1" == "pull" || "$1" == "fetch" ]]; then
echo Execute command: flock ~/.creds.lock -c 'chmod 400 ~/.gitconfig && command git config --global credential.helper store && command git '"$1 $COMM"' && chmod 644 ~/.gitconfig'
flock ~/.creds.lock -c 'chmod 400 ~/.gitconfig && (command git config --global credential.helper store && command git '"$1 $COMM"' && chmod 644 ~/.gitconfig) || chmod 644 ~/.gitconfig'
else
echo Execute command: command git "$1 $COMM"
eval "command git $1 $COMM"
fi
}
export -f git
EOF
CMDD=""
var="issue-42 Mark's"' "pears"'
echo $var
arg=$(echo -e $var | sed -r "s/'/\\\'/g")
echo $arg
CMDD="$CMDD $'$arg'"
echo $CMDD
CMDD="commit -m $CMDD"
echo $CMDD
echo command git $CMDD
set -x
eval "command git $CMDD"
set +x
Last active
August 7, 2021 20:12
-
-
Save gorshkov-leonid/402cdf9bae3085c758207e5036013c49 to your computer and use it in GitHub Desktop.
wrap git command
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment