Skip to content

Instantly share code, notes, and snippets.

@andynu
Created January 21, 2010 20:05
Show Gist options
  • Save andynu/283144 to your computer and use it in GitHub Desktop.
Save andynu/283144 to your computer and use it in GitHub Desktop.
scm related zsh aliases (svn, svk, git)
# my scm related aliases
export clrsvn='sed \
-e "s/^\? \(.*\)/$(tput setaf 243) [?] \1$NC/" \
-e "s/^A \(.*\)/$(tput setaf 02) [A] \1$NC/" \
-e "s/^C \(.*\)/$(tput setaf 200) [C] \1$NC/" \
-e "s/^D \(.*\)/$(tput setaf 01) [D] \1$NC/" \
-e "s/^I \(.*\)/$(tput setaf 238) [I] \1$NC/" \
-e "s/^! \(.*\)/$(tput setaf 09) [!] \1$NC/" \
-e "s/^G \(.*\)/$(tput setaf 214) [G] \1$NC/" \
-e "s/^M \(.*\)/$(tput setaf 11) [M] \1$NC/" \
-e "s/^U \(.*\)/$(tput setaf 14) [U] \1$NC/" '
alias -g clrsvn="$clrsvn"
export clrdiff='sed \
-e "s/^\([\+>].*\)$/$GREEN\1$NC/" \
-e "s/^\([-<].*\)$/$RED\1$NC/"'
alias -g clrdiff="$clrdiff"
# subversion / svn
function changeset(){
rev=`ruby -e "puts '$1'.gsub(/[^0-9]/,'').to_i"`
rev_minus_one=`ruby -e "puts '$1'.gsub(/[^0-9]/,'').to_i-1"`
svn diff -r$rev_minus_one:$rev |clrdiff
svn log -r$rev
}
function svnhistgrep(){
term=$1;
file=$2;
# versions=`svn log $file | perl -ne 'print "$1 " if (/r(\d+)/)'` # bash version
versions=($(svn log $file | perl -ne 'print "$1 " if (/r(\d+)/)')) # zsh version
for r in $versions; do
echo "$file r$r";
svn cat -r$r $file | egrep -C 3 -n $term
done
}
function svncold(){
file=$1;
rev=`ruby -e "puts '$2'.gsub(/[^0-9]/,'').to_i"`
svn cat $file -r$rev > $file.r$rev
}
function svnlog() { svn log $* | ruby -ne 'o||=""; if /^-+$/ then puts o.gsub(/\n/," ")[0,200]; o=""; else o += $_ end' }
alias svnten='svnlog --limit 100 G `date +%Y-%m` H -n 10'
alias mysvnten='svnlog --limit 200 G `date +%Y-%m` G -i Andy H -n 10'
alias svnday='svnlog --limit 1000 G `date +%Y-%m-%d`'
alias svnmonth='svnlog --limit 1000 G `date +%Y-%m`'
alias mysvnday='svnday G -i Andy'
alias mysvnmonth='svnmonth G -i Andy'
alias cs=changeset
alias svnl='svn log -v -r HEAD'
alias svnl='svn log -v -r HEAD'
alias svnll='svn log --stop-on-copy'
alias svnlll='svn log'
alias svnla='svn log --stop-on-copy -v'
alias svnlla='svn log -v'
alias svnstat="svn stat | egrep -v 'target|\.project|\.classpath|\.settings|tags|TAGS' | $clrsvn"
alias svnup="svn up | grep -v target | $clrsvn"
alias svnignore="svn propset svn:ignore "
function svndiff() {
svn diff $* | clrdiff;
diffstat =(svn diff $*);
}
function svncommit() {
svnpwd=`pwd`;
svn commit --editor-cmd 'vim -c"r!svn diff $svnpwd|diffstat"';
}
function svngrep(){
svnlog --limit 1000 G $1
}
alias svng='svngrep'
alias svnc='svncommit'
# svk
alias svkstat="svk stat | egrep -v 'target|\.project|\.classpath|\.settings|tags|TAGS' | $clrsvn"
alias svkup="svk up | grep -v target | $clrsvn"
alias svkdiff="svk diff | $clrdiff;diffstat =(svk diff)";
# git
alias gitup="git stash && git svn fetch && git svn rebase && git stash apply"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment