Simple bash calculator
? () { echo "$*" | bc -l; }
Use like this:
bash$ ? 2*2 4
It should be easily modifiable for other shells/calculators.
Via: http://rentzsch.com/rock/longhand
TextSnippets > nickstenning > bash
1809 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Nick Stenning
? () { echo "$*" | bc -l; }
bash$ ? 2*2 4
function edithosts { if [ -x "`which $EDITOR`" ] || [ -x "`which $1`" ] then if [ -x "`which $EDITOR`" ] then export TEMP_EDIT="`which $EDITOR`" else export TEMP_EDIT="`which $1`" fi echo "* Using ${TEMP_EDIT} as editor" $TEMP_EDIT /etc/hosts && echo "* Successfully edited /etc/hosts" lookupd -flushcache && echo "* Flushed local DNS cache" else echo "Usage: edithosts [editor]" echo "(The editor is optional, and defaults to \$EDITOR)" fi unset TEMP_EDIT }
lookupd -flushcache
cd ~ && ssh-keygen -t dsa
function scpdsa { if [[ -z "$1" ]]; then echo "!! You need to enter a hostname in order to send your public key !!" else echo "* Copying SSH public key to server..." ssh ${1} "mkdir -p ~/.ssh && cat - >> ~/.ssh/authorized_keys" < ~/.ssh/id_dsa.pub echo "* All done!" fi }
if [ "$TERM" != 'dumb' ] && [ -n "$BASH" ] && [ -n "$PS1" ] then if [ `/usr/bin/whoami` = 'root' ] then export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]' else export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]' fi fi