Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit f36c699f3741cc6ec59dc6dc501a1f2a5f6fea86 0 parents
@derekwyatt authored
2  .gitignore
@@ -0,0 +1,2 @@
+*.sw[op]
+perforce.sh
1  README
@@ -0,0 +1 @@
+A set of dotfiles that I need
122 bashprompt
@@ -0,0 +1,122 @@
+#!/bin/bash
+
+set -o allexport
+function prompt_command
+{
+ TERMWIDTH=${COLUMNS}
+
+ hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
+
+ usernam=$(whoami)
+ cur_tty=$(tty | sed -e "s/.*tty\(.*\)/\1/")
+ newPWD="${PWD}"
+ gitBranch=$(git branch 2>/dev/null | grep '^\*' | cut -c3-)
+ if [[ -z "$gitBranch" ]]; then
+ gitBranch=" "
+ else
+ gitBranch="$gitBranch"
+ fi
+ let promptsize=$(echo -n "--(${usernam}@${hostnam})-[$gitBranch]-(${PWD})--" | wc -c | tr -d " ")
+ let fillsize=${TERMWIDTH}-${promptsize}
+ fill=""
+ while [ "$fillsize" -gt "0" ]
+ do
+ fill="${fill}-"
+ let fillsize=${fillsize}-1
+ done
+
+ if [ "$fillsize" -lt "0" ]
+ then
+ let cut=3-${fillsize}
+ newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cut\}\)\(.*\)/\2/")"
+ fi
+}
+
+PROMPT_COMMAND=prompt_command
+
+function setXtermTitle
+{
+ export XTERM_TITLE=
+ if [ $TERM == xterm ]; then
+ if [ -n "$PERFORCE_PROJECT" ]; then
+ typeset proj="[$PERFORCE_PROJECT]"
+ else
+ typeset proj=
+ fi
+ typeset title="$proj"
+ if [ $# != 0 ]; then
+ title="$*${proj:+ $proj}"
+ fi
+ if [ -n "$title" ]; then
+ title="$title: "
+ fi
+ typeset h=
+ if [ "$HOSTNAME" != "dqw-linux" ]; then
+ h="$HOSTNAME:"
+ fi
+ XTERM_TITLE="\[\033]0;$h${title}\w\007\]"
+ else
+ XTERM_TITLE=
+ fi
+ twtty
+}
+
+alias st=setXtermTitle
+
+function twtty
+{
+ local GRAY="\[\033[1;30m\]"
+ local LIGHT_GRAY="\[\033[0;37m\]"
+ local WHITE="\[\033[1;37m\]"
+ local NO_COLOUR="\[\033[0m\]"
+
+ local LIGHT_BLUE="\[\033[1;34m\]"
+
+ local RED="\[\033[0;31m\]"
+ local BRIGHT_RED="\[\033[1;31m\]"
+
+ local CYAN="\[\033[0;36m\]"
+ local BRIGHT_CYAN="\[\033[1;36m\]"
+
+ local YELLOW="\[\033[0;33m\]"
+ local BRIGHT_YELLOW="\[\033[1;33m\]"
+
+ local GREEN="\[\033[0;32m\]"
+ local BRIGHT_GREEN="\[\033[1;32m\]"
+
+ if [ "$(hostname)" == "lambda.local" ]; then
+ ((SHLVL=SHLVL+1))
+ fi
+ if [ $SHLVL -lt 2 ]; then
+ local BASIC_TEXT="$GREEN"
+ local BRIGHT_TEXT="$BRIGHT_GREEN"
+ local DELIM_TEXT="$LIGHT_BLUE"
+ local BRANCH_TEXT="$BRIGHT_RED"
+ elif [ $SHLVL -lt 3 ]; then
+ local BASIC_TEXT="$YELLOW"
+ local BRIGHT_TEXT="$BRIGHT_YELLOW"
+ local DELIM_TEXT="$LIGHT_BLUE"
+ local BRANCH_TEXT="$BRIGHT_GREEN"
+ elif [ $SHLVL -lt 4 ]; then
+ local BASIC_TEXT="$CYAN"
+ local BRIGHT_TEXT="$BRIGHT_CYAN"
+ local DELIM_TEXT="$LIGHT_BLUE"
+ local BRANCH_TEXT="$BRIGHT_GREEN"
+ else
+ local BASIC_TEXT="$RED"
+ local BRIGHT_TEXT="$BRIGHT_RED"
+ local DELIM_TEXT="$LIGHT_BLUE"
+ local BRANCH_TEXT="$YELLOW"
+ fi
+ if [ "$(whoami)" = "root" ]; then
+ local USER_TEXT="\[\033[0;41m\]\[\033[1;37m\]"
+ else
+ local USER_TEXT=$BASIC_TEXT
+ fi
+
+ PS1="$XTERM_TITLE$BASIC_TEXT-$DELIM_TEXT-($USER_TEXT\$usernam$NO_COLOUR$DELIM_TEXT@$BASIC_TEXT\$hostnam${DELIM_TEXT})-${DELIM_TEXT}[${BRANCH_TEXT}\$gitBranch${DELIM_TEXT}]-($BRIGHT_TEXT\${newPWD}$DELIM_TEXT)-$BASIC_TEXT\${fill}$BASIC_TEXT-\n$BASIC_TEXT-$DELIM_TEXT->$NO_COLOUR "
+ PS2="$DELIM_TEXT-$BASIC_TEXT-$BASIC_TEXT-$NO_COLOUR "
+}
+
+setXtermTitle
+set +o allexport
272 bashrc
@@ -0,0 +1,272 @@
+
+set -o vi
+set -o ignoreeof
+
+export PATH=.:/usr/local/bin:~/bin:$PATH
+if uname | grep -q Darwin; then
+ export EDITOR="/usr/local/bin/mvim -f"
+else
+ export EDITOR=vim
+fi
+
+export JAVA_HOME=/usr/local/jdk
+
+# don't put duplicate lines in the history. See bash(1) for more options
+# ... or force ignoredups and ignorespace
+export HISTCONTROL=ignoredups:ignorespace
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+export HISTSIZE=1000
+export HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+eval "$(dircolors -b ~/.dircolors)"
+alias ls='ls --color=auto -F'
+alias grep='grep --color=auto'
+alias fgrep='fgrep --color=auto'
+alias egrep='egrep --color=auto'
+
+function g
+{
+ if uname | grep -q Darwin; then
+ mvim --remote-silent $@
+ else
+ gvim --remote-silent $@
+ fi
+}
+
+export DIRSTACK_MAX=15
+DS=()
+
+function eecho
+{
+ echo $@ 1>&2
+}
+
+function shiftStackUp
+{
+ typeset num=$1
+ typeset -i c=$((num+1))
+
+ while (( $c < ${#DS[*]} ))
+ do
+ DS[$((c-1))]="${DS[$c]}"
+ ((c=c+1))
+ done
+ unset DS[$((${#DS[*]}-1))]
+}
+
+function shiftStackDown
+{
+ typeset num=$1
+ typeset -i c=${#DS[*]}
+
+ while (( $c > $num ))
+ do
+ DS[$c]="${DS[$((c-1))]}"
+ ((c=c-1))
+ done
+}
+
+function popStack
+{
+ if [[ ${#DS[*]} == 0 ]]; then
+ eecho "Cannot pop stack. No elements to pop."
+ return 1
+ fi
+ typeset retv="${DS[0]}"
+ shiftStackUp 0
+
+ echo $retv
+}
+
+function pushStack
+{
+ typeset newvalue="$1"
+ typeset -i c=0
+
+ while (( $c < ${#DS[*]} ))
+ do
+ if [[ "${DS[$c]}" == "$newvalue" ]]; then
+ shiftStackUp $c
+ else
+ ((c=c+1))
+ fi
+ done
+ shiftStackDown 0
+ DS[0]="$newvalue"
+ if [[ ${#DS[*]} -gt $DIRSTACK_MAX ]]; then
+ unset DS[$((${#DS[*]}-1))]
+ fi
+}
+
+function cd_
+{
+ typeset ret=0
+
+ if [ $# == 0 ]; then
+ pd "$HOME"
+ ret=$?
+ elif [[ $# == 1 && "$1" == "-" ]]; then
+ pd
+ ret=$?
+ elif [ $# -gt 1 ]; then
+ typeset from="$1"
+ typeset to="$2"
+ typeset c=0
+ typeset path=
+ typeset x=$(pwd)
+ typeset numberOfFroms=$(echo $x | tr '/' '\n' | grep "^$from$" | wc -l)
+ while [ $c -lt $numberOfFroms ]
+ do
+ path=
+ typeset subc=$c
+ typeset tokencount=0
+ for subdir in $(echo $x | tr '/' '\n' | tail -n +2)
+ do
+ if [[ "$subdir" == "$from" ]]; then
+ if [ $subc -eq $tokencount ]; then
+ path="$path/$to"
+ subc=$((subc+1))
+ else
+ path="$path/$from"
+ tokencount=$((tokencount+1))
+ fi
+ else
+ path="$path/$subdir"
+ fi
+ done
+ if [ -d "$path" ]; then
+ break
+ fi
+ c=$((c=c+1))
+ done
+ if [ "$path" == "$x" ]; then
+ echo "Bad substitution"
+ ret=1
+ else
+ pd "$path"
+ ret=$?
+ fi
+ else
+ pd "$1"
+ ret=$?
+ fi
+
+ return $ret
+}
+
+function pd
+{
+ typeset dirname="${1-}"
+ typeset firstdir seconddir ret p oldDIRSTACK
+
+ if [ "$dirname" == "" ]; then
+ firstdir=$(pwd)
+ if [ ${#DS[*]} == 0 ]; then
+ eecho "Stack is empty. Cannot swap."
+ return 1
+ fi
+ seconddir=$(popStack)
+ pushStack "$firstdir"
+ "cd" "$seconddir"
+ ret=$?
+ return $ret
+ else
+ if [ -d "$dirname" ]; then
+ if [ "$dirname" != '.' ]; then
+ pushStack "$(pwd)"
+ fi
+ "cd" "$dirname"
+ ret=$?
+ return $ret
+ else
+ eecho "bash: $dirname: not found"
+ return 1
+ fi
+ fi
+}
+
+function ss
+{
+ typeset f x
+ typeset -i c=0
+ typeset re="${1-}"
+
+ while (( $c < ${#DS[*]} ))
+ do
+ f=${DS[$c]}
+ if [[ -n "$re" && "$(echo $f | grep $re)" == "" ]]; then
+ ((c=c+1))
+ continue
+ fi
+ if (( ${#f} > 120 )); then
+ x="...$(echo $f | cut -c$((${#f}-120))-)"
+ else
+ x=$f
+ fi
+ echo "$((c+1))) $x"
+ ((c=c+1))
+ done
+}
+
+function csd
+{
+ typeset num="${1-}"
+ typeset removedDirectory
+
+ if ! echo "${num##+([0-9])}" | grep -q '^[0-9][0-9]*$'; then
+ c=0
+ re=$num
+ num=0
+ while [ "$c" -lt "${#DS[*]}" ]
+ do
+ if echo "${DS[$c]}" | grep -q $re; then
+ num=$(($c+1))
+ break
+ fi
+ ((c=c+1))
+ done
+ fi
+ if [ "$num" == 0 ]; then
+ echo "usage: csd <number greater than 0 | regular expression>"
+ return 1
+ elif [ "$num" -gt "${#DS[*]}" ]; then
+ echo "$num is beyond the stack size."
+ return 1
+ else
+ num=$((num-1))
+ typeset dir="${DS[$num]}"
+ shiftStackUp $num
+ cd_ "$dir"
+ return $?
+ fi
+}
+
+alias cd=cd_
+
+for f in $(ls ~/.bash/source_these/*);
+do
+ . $f
+done
+
+if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
+ . /etc/bash_completion
+fi
+
+if [ -f ~/.bashprompt ]; then
+ . ~/.bashprompt
+fi
+
+if [ -f ~/.bashrc_local ]; then
+ . ~/.bashrc_local
+fi
209 dircolors
@@ -0,0 +1,209 @@
+# Configuration file for dircolors, a utility to help you set the
+# LS_COLORS environment variable used by GNU ls with the --color option.
+# Copyright (C) 1996, 1999-2010 Free Software Foundation, Inc.
+# Copying and distribution of this file, with or without modification,
+# are permitted provided the copyright notice and this notice are preserved.
+# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
+# slackware version of dircolors) are recognized but ignored.
+# Below, there should be one TERM entry for each termtype that is colorizable
+
+TERM Eterm
+TERM ansi
+TERM color-xterm
+TERM con132x25
+TERM con132x30
+TERM con132x43
+TERM con132x60
+TERM con80x25
+TERM con80x28
+TERM con80x30
+TERM con80x43
+TERM con80x50
+TERM con80x60
+TERM cons25
+TERM console
+TERM cygwin
+TERM dtterm
+TERM eterm-color
+TERM gnome
+TERM gnome-256color
+TERM jfbterm
+TERM konsole
+TERM kterm
+TERM linux
+TERM linux-c
+TERM mach-color
+TERM mlterm
+TERM putty
+TERM rxvt
+TERM rxvt-256color
+TERM rxvt-cygwin
+TERM rxvt-cygwin-native
+TERM rxvt-unicode
+TERM rxvt-unicode256
+TERM screen
+TERM screen-256color
+TERM screen-256color-bce
+TERM screen-bce
+TERM screen-w
+TERM screen.linux
+TERM vt100
+TERM xterm
+TERM xterm-16color
+TERM xterm-256color
+TERM xterm-88color
+TERM xterm-color
+TERM xterm-debian
+
+# Below are the color init strings for the basic file types. A color init
+# string consists of one or more of the following numeric codes:
+# Attribute codes:
+# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+# Text color codes:
+# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
+# Background color codes:
+# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+#NORMAL 00 # no color code at all
+#FILE 00 # regular file: use no color at all
+RESET 0 # reset to "normal" color
+DIR 00;36 # directory
+LINK 01;30;40 # symbolic link. (If you set this to 'target' instead of a
+ # numerical value, the color is as for the file pointed to.)
+MULTIHARDLINK 00 # regular file with more than one link
+FIFO 40;33 # pipe
+SOCK 00;35 # socket
+DOOR 00;35 # door
+BLK 40;33;01 # block device driver
+CHR 40;33;01 # character device driver
+ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file
+SETUID 37;41 # file that is setuid (u+s)
+SETGID 30;43 # file that is setgid (g+s)
+CAPABILITY 30;41 # file with capability
+STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
+OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
+STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
+
+# This is for files with execute permission:
+EXEC 00;32
+
+# List any file extensions like '.gz' or '.tar' that you would like ls
+# to colorize below. Put the extension, a space, and the color init string.
+# (and any comments you want to add after a '#')
+# If you use DOS-style suffixes, you may want to uncomment the following:
+.cmd 00;32 # executables (bright green)
+.exe 00;32
+.com 00;32
+.btm 00;32
+.bat 00;32
+# Or if you want to colorize scripts even if they do not have the executable bit actually set.
+.sh 00;32
+.csh 00;32
+ # archives or compressed (bright red)
+.tar 00;31
+.tgz 00;31
+.arj 00;31
+.taz 00;31
+.lzh 00;31
+.lzma 00;31
+.tlz 00;31
+.txz 00;31
+.zip 00;31
+.z 00;31
+.Z 00;31
+.dz 00;31
+.gz 00;31
+.lz 00;31
+.xz 00;31
+.bz2 00;31
+.bz 00;31
+.tbz 00;31
+.tbz2 00;31
+.tz 00;31
+.deb 00;31
+.rpm 00;31
+.jar 00;31
+.rar 00;31
+.ace 00;31
+.zoo 00;31
+.cpio 00;31
+.7z 00;31
+.rz 00;31
+# image formats
+.jpg 00;35
+.jpeg 00;35
+.gif 00;35
+.bmp 00;35
+.pbm 00;35
+.pgm 00;35
+.ppm 00;35
+.tga 00;35
+.xbm 00;35
+.xpm 00;35
+.tif 00;35
+.tiff 00;35
+.png 00;35
+.svg 00;35
+.svgz 00;35
+.mng 00;35
+.pcx 00;35
+.mov 00;35
+.mpg 00;35
+.mpeg 00;35
+.m2v 00;35
+.mkv 00;35
+.ogm 00;35
+.mp4 00;35
+.m4v 00;35
+.mp4v 00;35
+.vob 00;35
+.qt 00;35
+.nuv 00;35
+.wmv 00;35
+.asf 00;35
+.rm 00;35
+.rmvb 00;35
+.flc 00;35
+.avi 00;35
+.fli 00;35
+.flv 00;35
+.gl 00;35
+.dl 00;35
+.xcf 00;35
+.xwd 00;35
+.yuv 00;35
+.cgm 00;35
+.emf 00;35
+# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
+.axv 00;35
+.anx 00;35
+.ogv 00;35
+.ogx 00;35
+# audio formats
+.aac 00;33
+.au 00;33
+.flac 00;33
+.mid 00;33
+.midi 00;33
+.mka 00;33
+.mp3 00;33
+.mpc 00;33
+.ogg 00;33
+.ra 00;33
+.wav 00;33
+# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
+.axa 00;33
+.oga 00;33
+.spx 00;33
+.xspf 00;33
+
+# My personal ones
+.c 00;37;44
+.C 00;37;44
+.cc 00;37;44
+.cpp 00;37;44
+.scala 00;37;44
+.java 00;33;41
+.h 00;33;41
+.H 00;33;41
+.hh 00;33;41
+.hpp 00;33;41
10 inputrc
@@ -0,0 +1,10 @@
+set bell-style none
+$if mode=vi
+ set keymap vi-command
+ "gg": beginning-of-history
+ "G": end-of-history
+ set keymap vi-insert
+ "jj": vi-movement-mode
+ "\C-w": backward-kill-word
+ "\C-p": history-search-backward
+$endif
147 source_these/aliases.sh
@@ -0,0 +1,147 @@
+#!/bin/bash
+
+# Reload these aliases
+alias ra='for f in ~/.bash/*; do . $f; done'
+
+# Code related aliases
+alias gdb="gdb --quiet"
+if ! uname | grep -q Darwin; then
+ alias open=gnome-open
+fi
+alias sc=screen
+alias scl="screen -list"
+
+function findWithSpec
+{
+ typeset dirs=
+ typeset egrepopts="-v '\\.sw[po]\\$|/\\.git/|^\\.git/'"
+ typeset nullprint=
+ while [[ $# != 0 ]];
+ do
+ if [[ "$1" == "-Z" ]]; then
+ egrepopts="-Zz $egrepopts"
+ nullprint="-print0"
+ shift
+ elif [[ -d "$1" ]]; then
+ dirs="$dirs '$1'"
+ shift
+ else
+ break
+ fi
+ done
+ if [[ -z "$dirs" ]]; then
+ dirs=.
+ fi
+ eval "find $dirs $nullprint $@ | egrep $egrepopts"
+}
+
+function findsrc
+{
+ findWithSpec "$@" '-name \*.java -o -name \*.scala -o -name Makefile -o -name \*.h -o -name \*.cpp -o -name \*.c'
+}
+alias findsrcz="findsrc -Z"
+
+function findj
+{
+ findWithSpec "$@" '-name \*.java'
+}
+alias findjz="findj -Z"
+
+function finds
+{
+ findWithSpec "$@" '-name \*.scala'
+}
+alias findsz="finds -Z"
+
+function findsj
+{
+ (finds "$@"; findj "$@")
+}
+alias findsjz="findsj -Z"
+
+function findh
+{
+ findWithSpec "$@" '-name \*.h -o -name \*.hpp'
+}
+alias findhz="findh -Z"
+
+function findc
+{
+ findWithSpec "$@" '-name \*.cpp -o -name \*.c'
+}
+alias findcz="findc -Z"
+
+function findch
+{
+ (findc "$@"; findh "$@")
+}
+alias findchz="findch -Z"
+
+function findf
+{
+ findWithSpec "$@" "-type f"
+}
+alias findfz="findf -Z"
+
+function findm
+{
+ findWithSpec "$@" "-name Makefile"
+}
+alias findmz="findm -Z"
+
+alias f=findWithSpec
+
+function findClass
+{
+ typeset pattern="${1-}"
+ if [ -z "$pattern" ]; then
+ echo "No pattern supplied" 1>&2
+ return 1
+ fi
+ echo $CLASSPATH | tr ':' '\n' | grep -v '^ *$' | \
+ while read entry
+ do
+ echo "====== $entry ======"
+ if [ "${entry%.jar}" != "$entry" ]; then
+ if [ -f "$entry" ]; then
+ jar tf "$entry" | egrep $pattern
+ fi
+ elif [ -d "$entry" ]; then
+ find "$entry" | egrep -i $pattern
+ fi
+ done
+}
+
+# Assorted
+alias swps='find . -name .\*.sw[op]'
+alias rmstd='xargs rm -vf'
+alias xag='xargs -0 egrep'
+
+# some ls aliases
+alias ll='ls -halF'
+alias la='ls -A'
+alias l='ls -CF'
+
+# programs
+alias firefox='firefox -P default'
+function ff
+{
+ if [ $# = 0 ]; then
+ echo "usage: ff <file>" 1>&2
+ return 1
+ fi
+ if [ -d "$1" ]; then
+ echo "That's a directory, dumbass." 1>&2
+ return 1
+ elif [ "${1%/*}" = "$1" ]; then
+ firefox -new-tab "file://$(pwd)/$1"
+ else
+ \cd "${1%/*}"
+ typeset dir="$(pwd)"
+ \cd - >/dev/null
+ firefox -new-tab "file://$dir/${1##*/}"
+ fi
+ return 0
+}
+
+alias pg='ps -ef | grep '
16 source_these/git.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+alias gls='git status --porcelain'
+alias gc='git commit'
+alias ga='git add'
+alias gpu='git push'
+alias gpl='git pull'
+alias gco='git checkout'
+alias gd='git diff'
+alias gb='git branch'
+alias gbl='git branch --list'
+alias gm='git merge'
+alias ggls='for f in $(find . -name .git -a -type d); do d=${f%/.git}; echo ---- $d; (cd $d; git status --porcelain); done'
+alias addM='git status --porcelain | grep "^.M " | cut -c4- | xargs git add'
+alias addQ='git status --porcelain | grep "^?? " | cut -c4- | xargs git add'
+alias addD='git status --porcelain | grep "^.D " | cut -c4- | xargs git rm'
376 zshrc
@@ -0,0 +1,376 @@
+# Path to your oh-my-zsh configuration.
+ZSH=$HOME/.oh-my-zsh
+ZSH_THEME="gnzh"
+# Set to this to use case-sensitive completion
+# CASE_SENSITIVE="true"
+
+# Comment this out to disable weekly auto-update checks
+# DISABLE_AUTO_UPDATE="true"
+
+# Uncomment following line if you want to disable colors in ls
+# DISABLE_LS_COLORS="true"
+
+# Uncomment following line if you want to disable autosetting terminal title.
+# DISABLE_AUTO_TITLE="true"
+
+# Uncomment following line if you want red dots to be displayed while waiting for completion
+COMPLETION_WAITING_DOTS="true"
+
+plugins=(git vi-mode)
+source $ZSH/oh-my-zsh.sh
+
+bindkey -M viins 'jj' vi-cmd-mode
+
+if [ $(uname) = Darwin ]; then
+ export PATH=.:~/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+else
+ export PATH=.:buildutil:/home/dwyatt/local/bin:/home/dwyatt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/qnx650/host/linux/x86/usr/bin:/etc/qnx/bin
+fi
+
+export GPGKEY=B2F6D883
+export GPG_TTY=$(tty)
+
+export EDITOR=/usr/local/bin/vim
+export JAVA_HOME=/usr/local/jdk
+
+if which dircolors > /dev/null; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto -F'
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+
+function gg
+{
+ if uname | grep -q Darwin; then
+ mvim --remote-silent $@
+ else
+ gvim --remote-silent $@
+ fi
+}
+
+function eecho
+{
+ echo $@ 1>&2
+}
+
+function findWithSpec
+{
+ local dirs=
+ local egrepopts="-v '\\.sw[po]\\$|/\\.git/|^\\.git/'"
+ local nullprint=
+ while [[ $# != 0 ]];
+ do
+ if [[ "$1" == "-Z" ]]; then
+ egrepopts="-Zz $egrepopts"
+ nullprint="-print0"
+ shift
+ elif [[ -d "$1" ]]; then
+ dirs="$dirs '$1'"
+ shift
+ else
+ break
+ fi
+ done
+ if [[ -z "$dirs" ]]; then
+ dirs=.
+ fi
+ eval "find $dirs $nullprint $@ | egrep $egrepopts"
+}
+
+function findsrc
+{
+ findWithSpec "$@" '-name \*.java -o -name \*.scala -o -name Makefile -o -name \*.h -o -name \*.cpp -o -name \*.c'
+}
+alias findsrcz="findsrc -Z"
+
+function findj
+{
+ findWithSpec "$@" '-name \*.java'
+}
+alias findjz="findj -Z"
+
+function finds
+{
+ findWithSpec "$@" '-name \*.scala'
+}
+alias findsz="finds -Z"
+
+function findsj
+{
+ (finds "$@"; findj "$@")
+}
+alias findsjz="findsj -Z"
+
+function findh
+{
+ findWithSpec "$@" '-name \*.h -o -name \*.hpp'
+}
+alias findhz="findh -Z"
+
+function findc
+{
+ findWithSpec "$@" '-name \*.cpp -o -name \*.c'
+}
+alias findcz="findc -Z"
+
+function findch
+{
+ (findc "$@"; findh "$@")
+}
+alias findchz="findch -Z"
+
+function findf
+{
+ findWithSpec "$@" "-type f"
+}
+alias findfz="findf -Z"
+
+function findm
+{
+ findWithSpec "$@" "-name Makefile"
+}
+alias findmz="findm -Z"
+
+alias f=findWithSpec
+
+function findClass
+{
+ local pattern="${1-}"
+ if [ -z "$pattern" ]; then
+ eecho "No pattern supplied" 1>&2
+ return 1
+ fi
+ echo $CLASSPATH | tr ':' '\n' | grep -v '^ *$' | \
+ while read entry
+ do
+ echo "====== $entry ======"
+ if [ "${entry%.jar}" != "$entry" ]; then
+ if [ -f "$entry" ]; then
+ jar tf "$entry" | egrep $pattern
+ fi
+ elif [ -d "$entry" ]; then
+ find "$entry" | egrep -i $pattern
+ fi
+ done
+}
+
+function ff
+{
+ if [ $# = 0 ]; then
+ eecho "usage: ff <file>" 1>&2
+ return 1
+ fi
+ if [ -d "$1" ]; then
+ eecho "That's a directory, dumbass." 1>&2
+ return 1
+ elif [ "${1%/*}" = "$1" ]; then
+ firefox -new-tab "file://$(pwd)/$1"
+ else
+ "cd" "${1%/*}"
+ local dir="$(pwd)"
+ "cd" - >/dev/null
+ firefox -new-tab "file://$dir/${1##*/}"
+ fi
+ return 0
+}
+
+function gitnotify
+{
+ if [[ ! -d .git ]]; then
+ eecho "You're not in a git repository dumbass"
+ return 1
+ fi
+ local proj="$(basename $(pwd))"
+ local commit=$(git log -1 | head -1 | awk '{print $2}')
+ local url="$(printf 'http://gitweb.rim.net/?p=users/dwyatt/%s.git;a=commit;h=%s' $proj $commit)"
+ for user in $*
+ do
+ local email=
+ case $user in
+ ron) email=ropuri@rim.com
+ ;;
+ derek) email=dwyatt@rim.com
+ ;;
+ esac
+ if [[ -n $email ]]; then
+ ssmtp $email <<EOH
+ To: $email
+ From: dwyatt@rim.com
+ Subject: Commit on $proj
+ Content-Type: text/html; charset="us-ascii"
+ <html>
+ <a href='$url'>$commit</a>
+ </html>
+EOH
+ eecho "sent notification to $user ($email)"
+ fi
+ done
+}
+
+# Assorted
+alias swps='find . -name .\*.sw[op]'
+alias rmstd='xargs rm -vf'
+alias xag='xargs -0 egrep'
+
+alias open=gnome-open
+alias sc=screen
+alias scl="screen -list"
+
+function eecho
+{
+ echo $@ 1>&2
+}
+
+function pd
+{
+ local dirname="${1-}"
+ local firstdir seconddir ret p oldDIRSTACK
+
+ if [ "$dirname" = "" ]; then
+ firstdir=$(pwd)
+ if [ ${#DS[*]} = 0 ]; then
+ eecho "Stack is empty. Cannot swap."
+ return 1
+ fi
+ seconddir=$(popStack)
+ pushStack "$firstdir"
+ "cd" "$seconddir"
+ ret=$?
+ return $ret
+ else
+ if [ -d "$dirname" ]; then
+ if [ "$dirname" != '.' ]; then
+ pushStack "$(pwd)"
+ fi
+ "cd" "$dirname"
+ ret=$?
+ return $ret
+ else
+ eecho "zsh: $dirname: not found"
+ return 1
+ fi
+ fi
+}
+
+function cd_
+{
+ local ret=0
+
+ if [ $# = 0 ]; then
+ pd "$HOME"
+ ret=$?
+ elif [[ $# == 1 && "$1" == "-" ]]; then
+ pd
+ ret=$?
+ elif [ $# -gt 1 ]; then
+ local from="$1"
+ local to="$2"
+ local c=0
+ local path=
+ local x=$(pwd)
+ local numberOfFroms=$(echo $x | tr '/' '\n' | grep "^$from$" | wc -l)
+ while [ $c -lt $numberOfFroms ]
+ do
+ path=
+ local subc=$c
+ local tokencount=0
+ for subdir in $(echo $x | tr '/' '\n' | tail -n +2)
+ do
+ if [[ "$subdir" == "$from" ]]; then
+ if [ $subc -eq $tokencount ]; then
+ path="$path/$to"
+ subc=$((subc+1))
+ else
+ path="$path/$from"
+ tokencount=$((tokencount+1))
+ fi
+ else
+ path="$path/$subdir"
+ fi
+ done
+ if [ -d "$path" ]; then
+ break
+ fi
+ c=$((c=c+1))
+ done
+ if [ "$path" == "$x" ]; then
+ eecho "Bad substitution"
+ ret=1
+ else
+ pd "$path"
+ ret=$?
+ fi
+ else
+ pd "$1"
+ ret=$?
+ fi
+
+ return $ret
+}
+
+function popStack
+{
+ if [[ ${#DS[*]} == 0 ]]; then
+ eecho "Cannot pop stack. No elements to pop."
+ return 1
+ fi
+ local retv="${DS[1]}"
+ set -A DS ${DS[2,-1]}
+
+ echo $retv
+}
+
+function pushStack
+{
+ set -A DS "$1" ${DS[1,-1]}
+}
+
+function ss
+{
+ local c=1
+ for f in $DS
+ do
+ if (( ${#f} > 100 )); then
+ x="...$(echo $f | cut -c$((${#f}-100))-)"
+ else
+ x=$f
+ fi
+ echo "$c) $x"
+ ((c=c+1))
+ done
+}
+
+function csd
+{
+ local num="${1-}"
+
+ if ! echo "$num" | grep -q '^[0-9][0-9]*$'; then
+ c=1
+ re=$num
+ num=1
+ while [ "$c" -le "${#DS[*]}" ]
+ do
+ if echo "${DS[$c]}" | grep -q $re; then
+ num=$c
+ break
+ fi
+ ((c=c+1))
+ done
+ fi
+ if [ $num = 0 ]; then
+ eecho "usage: csd <number greater than 0 | regex>"
+ return 1
+ elif [ $num -gt ${#DS[*]} ]; then
+ eecho $num is beyond the stack size.
+ return 1
+ else
+ local dir=${DS[$num]}
+ set -A DS ${DS[1,$((num-1))]} ${DS[$((num+1)),-1]}
+ cd_ "$dir"
+ return $?
+ fi
+}
+
+alias cd=cd_
Please sign in to comment.
Something went wrong with that request. Please try again.