1
0
mirror of https://github.com/aquatix/dotfiles.git synced 2025-12-06 21:45:10 +01:00

Moved git version fallback to bashrc

This commit is contained in:
Michiel Scholten
2014-12-09 13:36:22 +01:00
parent 84b8c4deb0
commit 2650f61fdc
2 changed files with 42 additions and 40 deletions

View File

@@ -1,45 +1,5 @@
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) git config --global push.default matching; git config --global pull.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)"
@@ -98,6 +58,7 @@ alias so=git
# so rebase
# so diff
# mercurial coloured diff
alias hgd='hg diff | colordiff -y | less -R'
# 20140521 force 256 colours in tmux
@@ -117,6 +78,7 @@ alias tmux_reload="tmux source-file ~/.tmux.conf"
alias dcpvag='workon dcp; cd ~/workspace/sanoma/content-library/; vagrant ssh'
alias dcpsrc='cd development/current/content-library/src/content_library/; . ~/development/env/bin/activate'
# if you're really annoyed with a runaway process
function fuck() {
if killall -9 "$2"; then
echo ; echo " (╯°□°)╯︵$(echo "$2"|toilet -f term -F rotate)"; echo

40
.bashrc
View File

@@ -56,6 +56,46 @@ if [ -n "$force_color_prompt" ]; then
fi
fi
# 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; it supports 'simple' from 1.7.11 up, fall back to 'matching'
vercomp "1.7.11" `git --version|awk '{ print $3 }'`
case $? in
0) op='=';;
1) git config --global push.default matching; git config --global pull.default matching ;; # op='>';;
2) op='<';;
esac
hg_ps1() {
#hg prompt "{ on {branch}}{ at {bookmark}}{status}" 2> /dev/null
hg prompt " \[\033[1;37m\]hg\[\033[0m\] {branch}{status}" 2> /dev/null