fix gc and gcm

This commit is contained in:
wsq 2019-08-12 17:13:08 +08:00
parent 2420c13326
commit 5e7f99c2ed

View File

@ -350,29 +350,35 @@ function dc {
function get_ip_of_ssh_hostname { function get_ip_of_ssh_hostname {
ssh -G $1 | awk '/^hostname / { print $2 }' ssh -G $1 | awk '/^hostname / { print $2 }'
} }
function gcn { unalias gc
unalias gcm
function gc {
while true;do while true;do
typeset -A users users=($GIT_USERS)
users=('1' 'hophacker' '2' 'zhcalvin' '6' 'wsq') for ((i=1; i<=${#users[@]}; i++)) do
for k in "${(@k)users}"; do echo "$i | $users[$i]"
echo "$k || $users[$k]"
done done
echo 'please input your number or name:'
read input read input
if [[ ! -z $users[$input] ]];then for ((i=1; i<=${#users[@]}; i++)) do
name=$users[$input] if [[ $input == $users[$i] ]];then
break
else
for k in "${(@k)users}"; do
if [[ $input == $users[$k] ]];then
name=$input name=$input
index=$i
break 2 break 2
elif [[ "$input" =~ '^[0-9]+$' ]];then
if [[ $input -gt 0 && $input -le ${#users[@]} ]];then
name=$users[$input]
index=$input
break 2
fi
fi fi
done done
echo 'invalid option...' echo 'invalid option...'
fi
done done
typeset -A emails emails=($GIT_EMAILS)
emails=('hophacker' 'j' 'zhcalvin' 'c' 'wsq' 'wsq') (git commit --verbose $*) || return
set -x (git commit --amend --author="$name <$emails[$index]>") || return
git commit --amend --author="$name<$emails[$name]@paiyou.co>" $* }
function gcm {
(gc --message $*) || return
} }