dotfiles / profile

# The all-mighty profile!
#  It will always get loaded before the zshrc or bashrc
#   (or, at least, bashrc and zshrc will source it)

[[ "${PROFILE_LOADED-}" ]] && return 0
export PROFILE_LOADED=1

#export ECF="woleverd@p`expr '(' $RANDOM % 5 ')' + 1`.ecf.utoronto.ca"
export ECF="woleverd@p164.ecf.utoronto.ca"
export ES="ensisolutions@ensisolutions.com"
export ESOFFICE="guillermo.psxjst1.net"
export CDF="g7woleve@cdf.toronto.edu"
export CS="cs.toronto.edu"
export SWC="swc@swc.scipy.org"
export TB="thirdbit@third-bit.com"
export NFS="wolever_wolever@ssh.phx.nearlyfreespeech.net"
export BASIE="-p42 wolever@basieproject.org"

export PIP_DOWNLOAD_CACHE="$HOME/.pip/cache/"
[[ ! -d "$PIP_DOWNLOAD_CACHE" ]] && mkdir -p "$PIP_DOWNLOAD_CACHE"

export NNTPSERVER='freenews.netfront.net'

export NAME="David Wolever"
export EDITOR="vim"
export PYTHONSTARTUP=~/.pythonrc
export LANG="en_US.UTF-8"
export LANGUAGE="$LANG"
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
export HISTIGNORE="&:bg:fg:exit"
export HISTFILESIZE=10000

# These should be local on machines that don't like the mac's terminal
#export TERM="xterm-color" 
#export TERMINFO="$HOME/.terminfo"

rmext() {
    find . -name "*.$1" | head
    echo "Remove all .$1 files?"
    read RESP
    [[ "$RESP" =~ [nN] ]] && { echo "Abort."; return 1; }
    find . -name "*.$1" -delete
}
alias rmorig="rmext orig"
alias rmrej="rmext rej"

alias ls="ls --color=auto"
alias la="ls -alh"
alias grep="grep --color=auto --exclude='*.svn*'"
alias resize="resize; clear"
alias py="python"
alias ipy="ipython"

vs() {
    # Guesses which version control system is correct for the current
    # directory, then executes it with "${@}":
    #   $ cd hg_repo/
    #   $ vs version
    #   Mercurial Distributed SCM
    #   ...
    #   $ cd ../git_repo
    #   $ vs version
    #   git version 1.8.1.1
    local vcs
    vcs="$(vsname)" || {
        echo "error: not in a VCS repository." >&2
        return 1
    }
    "$vcs" "${@}"
    return $?
}

vsname() {
    # Guesses which version control system is correct for the current
    # directory:
    #    $ cd hg_repo/
    #    $ vsname
    #    hg
    #    $ cd ../git_repo
    #    $ vsname
    #    git
    #    $ cd /tmp/
    #    $ vsname
    #    $ echo $?
    #    1
    local test_vcses=( "hg" "git" )
    local vcs=""
    local dir="$PWD"
    while [[ "$dir" > "/" ]]; do
        local test_vcs
        for test_vcs in "${test_vcses[@]}"; do
            if [[ -d "$dir/.$test_vcs" ]]; then
                vcs="$test_vcs"
                break;
            fi
        done
        dir="${dir%/*}"
    done

    if [[ -z "$vcs" ]]; then
        return 1
    fi

    echo "$vcs"
    return 0
}

alias glog="vs glog | less"
alias viq="vim \$(vs root)/.$(vsname)/patches/series"
for vscmd in tip qimport qser qpo qpop qpu qpush qfin qref qnew qrm qmv di ci qdi st rebase pull nudge sum co bm
do
    alias $vscmd="vs $vscmd"
done
alias push="vs nudge"

# Add our own bin/ directory to PATH
export PATH="$HOME/.bin:$PATH"

_pyexpect() {
    expect -c "
        spawn -noecho ipython
        expect \"In \"
        send \"$*\n\"
        interact +++ return
    ";
}

alias from="_pyexpect from"
alias import="_pyexpect import"

. ~/.profile.local
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.