diff --git a/.bash_aliases b/.bash_aliases index 341a822..7b615cc 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,5 +1,45 @@ PATH=$PATH:~/bin +# http://stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format +vercomp () { + if [[ $1 == $2 ]] + then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 +} + +# check version of git +vercomp "1.7.11" `git --version|awk '{ print $3 }'` +case $? in + 0) op='=';; + 1) alias git='git config --global push.default matching';; # op='>';; + 2) op='<';; +esac + # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"