I use bash and vi basically as my IDE, so here are a few of my favorite functions. Hopefully people out there can use these functions as a basis to customize their own shell to really be maximally productive.
This is a straightforward Hamming encoding of one of my most common commands.
alias g='grails'
This prints out the bytecode of a Java class file, along with all the extra noise possible.
alias bytecode="javap -c -l -private -s -verbose"
And shorthand for opening a file read-only, because sometimes you don’t want to break stuff.
alias vir="vi -R"
Open a file that’s not the SVN copy or the compiled *.class file that starts with the given name.
function vif { FIND_ME="$1*" vi `find . -iname $FIND_ME -and -not -iname '*.svn*' -and -not -ipath '*/.svn/*' -and -not -iname '*.class'` }
This fires off testing for the app. This will be a lot easier in Grails now that plugins can hook into the test-app command: looking forward to that.
function gta { rm -rfv stacktrace.log ./test/reports ./test/reports-functional grails clean #time grails functional-tests #mv ./test/reports ./test/reports-functional #open ./test/reports-functional/html/index.html time grails run-webtest time grails test-app $@ open ./test/reports/html/index.html }
This prints out the error codes, as documented by errno.
function errcodes { perl -MErrno -e 'my %e= map { Errno->$_()=>$_ } keys(%!); print grep ! +/unknown error/i, map sprintf("%4d %-12s %s".$/,$_,$e{$_},$!=$_), 0.. +127' }
And, courtesy of Ruby.MN, this one looks up a word in Apple’s Dictionary.
function dict { open "dict://$1" }
And this one (for OCaml) looks up the interface for a library.
function mli { TARG=`ocamlfind query $1` vi -R $TARG/$1.mli }
One Comment
Here’s a useful little shell script that would validate a long list of Web proxies in just a couple of minutes. Just thought people here may find it useful: http://www.krazyworks.com/automatically-validate-http-proxies/