Skip to content

Instantly share code, notes, and snippets.

@mtak
Created March 13, 2012 15:05

Revisions

  1. Merijntje Tak created this gist Mar 13, 2012.
    58 changes: 58 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    # Terminal options
    shopt -s histappend
    shopt -s cdspell
    #PROMPT_COMMAND='history -a'
    HISTFILESIZE=5000
    HISTCONTROL=ignoredups
    TERM=xterm
    export PROMPT_COMMAND HISTFILESIZE HISTCONTROL TERM

    # Aliases
    alias sl=ls
    alias ps="ps -efZ"
    alias grpe="grep"

    # Shell functions
    init () {
    hostname=`hostname`
    zoneadm list -vic | grep global >/dev/null;
    globalToggle=$?;
    echo "Are you sure you want to do init $* on machine ${hostname}?"
    if [ $globalToggle -eq 0 ]; then
    echo "THIS IS A GLOBAL MACHINE"
    fi
    read -p "Enter to continue or CTRL+C to abort..."
    /sbin/init $*
    }

    # Convert bytes to gigabytes and vice versa
    b2g () { echo $(($1/(1024*1024*1024))); }
    g2b () { echo $(($1*(1024*1024*1024))); }

    mailme () {
    uuencode $1 $1 | mailx -s "$1" user@example.com
    }

    # Coloured grep
    if [ -x "`which ggrep`" ]; then
    export GREP_COLOR='1;32'
    alias grep="`which ggrep` --color=auto"
    fi

    # Settings for local host
    if [ `hostname` = "thor" ]; then
    /usr/openwin/bin/xset b 0
    if [ `/usr/bin/id -u` = 101 ]; then
    /home/mtak/bin/ssh-agent_start_stop
    export SSH_AUTH_SOCK=`cat ~/.ssh_auth_sock`
    export SSH_AGENT_PID=`cat ~/.ssh_agent_pid`
    sshLines=`/usr/bin/ssh-add -l | grep -v "agent has no identities" | wc -l`
    if [ ${sshLines} = "0" ]; then
    echo "SSH key caching expired, please reenter your credentials"
    /usr/bin/ssh-add -t 30600
    fi
    fi
    else
    # Other systems don't deal well with rxvt
    export TERM=xterm
    fi