History expansion and substitions in ZSH

I better to keep that somewhere since i always forget that thing, to do a search and replace from the command line in zsh. you just have to do the :s^FOO^BAR after your expansion For example you just have typed the long command line : blah bar FOO=1 FOO=3 FOO=6 cnt=1 you can just type : !blah:s^FOO^VALUE^:G and it will be expanded to : blah bar VALUE=1 VALUE=3 VALUE=6 cnt=1

January 11, 2007

Get size of Postgres DB from filesystem

Get the size accurately from postgres local filesystem, i guess there is some sql stuff that can do that but that does the job as well for me : #!/bin/bash /usr/lib/postgresql/8.1/bin/oid2name -U postgres|while read -a e;do name=${e[1]} oid=${e[0]} [[ $oid == "All" || $oid == "Oid" || -z $oid || -z $name ]] && continue typeset -a size size=(`du -s /var/lib/postgresql/8.1/main/base/$oid`) size=${size[0]} printf "%-20s %-20s\n" ${name} ${size} done | sort -n -r -k 2 |awk '{printf "%-20s%20d Mb\n", $1, $2 / 1024}'

June 5, 2006

svn diff without spaces

I am sic of spaces and having svn diff that does not get the spaces removed. So here is a simple script that does the stuff that you can use as your diff-cmd : #!/bin/bash for i in $@;do echo $i |grep -q ")" && continue echo $i |grep -q "(" && continue t="$t $i" done diff -bBw $t

May 25, 2006