# .bashrc

if [ "$PS1" ]; then

        PSSH_PWD="$HOME/.ssh/pssh_pwd"
        if [ x"$HOME" = x ] ; then
                PSSH_PWD="`cd ~ ; pwd`/.ssh/pssh_pwd"
        fi

        alias pssh="history -a ; pwd > ${PSSH_PWD} ; ssh"

        if [ -f "${PSSH_PWD}" -a x"${SSH_TTY}" != x ] ; then
                DIR="`cat ${PSSH_PWD}`"
                cd $DIR
                rm -f "${PSSH_PWD}"
                export PWD="$DIR"
                exec /bin/bash
                echo "##### failed pssh thingy" >&2
        fi

        #
        # http://www.jukie.net/~bart/blog/screen-ssh-agent
        #
        _ssh_auth_save() {
                ln -sf "$SSH_AUTH_SOCK" "$HOME/.screen/ssh-auth-sock.$HOSTNAME"
        }
        alias screen='_ssh_auth_save ; export HOSTNAME=$(hostname) ; screen'

fi

