| 1 |
# ~/.zshrc
|
| 2 |
#
|
| 3 |
# $Revision$
|
| 4 |
# $Date$
|
| 5 |
# $Author$
|
| 6 |
#
|
| 7 |
|
| 8 |
# Vi keybindings
|
| 9 |
bindkey -v
|
| 10 |
|
| 11 |
# arrow keys are not properly bound in Ubuntu vi key bindings; bind them here
|
| 12 |
# from http://www.zsh.org/mla/users/2001/msg00074.html
|
| 13 |
bindkey -M viins '^[[D' vi-backward-char '^[[C' vi-forward-char '^[[A' up-line-or-history '^[[B' down-line-or-history
|
| 14 |
|
| 15 |
export EDITOR="vim" # programs will use this by default if you need to edit something
|
| 16 |
export VISUAL="vim" # some programs use this instead of EDITOR
|
| 17 |
|
| 18 |
# ensures that I can delete over stuff that was done in a previous insert
|
| 19 |
# session, not proper vi action
|
| 20 |
bindkey -M viins '' backward-delete-char
|
| 21 |
bindkey -M viins '' backward-delete-char
|
| 22 |
stty ek
|
| 23 |
|
| 24 |
# To discover the proper keys, in vi mode type: ^v then the key
|
| 25 |
bindkey '^[[3~' delete-char
|
| 26 |
bindkey '^[[7~' beginning-of-line
|
| 27 |
bindkey '^[[8~' end-of-line
|
| 28 |
|
| 29 |
HISTSIZE=5000
|
| 30 |
HISTFILE=~/.zsh_history
|
| 31 |
SAVEHIST=2000
|
| 32 |
setopt appendhistory
|
| 33 |
|
| 34 |
# PROMPT explination:
|
| 35 |
# $=' needed for colors
|
| 36 |
# %{\e[1;32m%} sets our first color. 32 is the color, changed as needed
|
| 37 |
# always end with color 00 so the CL is normal
|
| 38 |
# %n: username, %m: hostname, %1~: display the pwd (if $HOME then ~) one level
|
| 39 |
# %(!.#.$): if (su_priv) then # else $
|
| 40 |
PROMPT=$'%(!.%{\e[1;31m%}.%{\e[1;32m%})%n@%{\e[1;34m%}%m:%{\e[1;31m%}%1~%{\e[1;00m%}%(!.#.$) '
|
| 41 |
|
| 42 |
# RPROMPT (shows up at the end of a line)
|
| 43 |
# if (exit code wasn't bad) then else display the exit code
|
| 44 |
#RPROMPT='%(?..%?)'
|
| 45 |
RPROMPT=$'%{\e[0;31m%}%d %{\e[0;34m%}[%T]%{\e[0;00m%} %(?.%?.%?)'
|
| 46 |
|
| 47 |
# from http://dotfiles.org/~_why/.zshrc
|
| 48 |
# format titles for screen and rxvt
|
| 49 |
function title() {
|
| 50 |
# escape '%' chars in $1, make nonprintables visible
|
| 51 |
a=${(V)1//\%/\%\%}
|
| 52 |
|
| 53 |
# Truncate command, and join lines.
|
| 54 |
a=$(print -Pn "%40>...>$a" | tr -d "\n")
|
| 55 |
|
| 56 |
case $TERM in
|
| 57 |
screen)
|
| 58 |
print -Pn "\ek$a:$3\e\\" # screen title (in ^A")
|
| 59 |
;;
|
| 60 |
xterm*|rxvt)
|
| 61 |
print -Pn "\e]2;$2 | $a:$3\a" # plain xterm title
|
| 62 |
;;
|
| 63 |
esac
|
| 64 |
}
|
| 65 |
# precmd is called just before the prompt is printed
|
| 66 |
function precmd() {
|
| 67 |
title "zsh" "$USER@%m" "%55<...<%~"
|
| 68 |
}
|
| 69 |
# preexec is called just before any command line is executed
|
| 70 |
function preexec() {
|
| 71 |
title "$1" "$USER@%m" "%35<...<%~"
|
| 72 |
}
|
| 73 |
|
| 74 |
|
| 75 |
# Make cd actually do pushd too
|
| 76 |
setopt AUTO_PUSHD
|
| 77 |
setopt PUSHD_IGNORE_DUPS
|
| 78 |
|
| 79 |
# Enhances tab-completion
|
| 80 |
autoload -U compinit
|
| 81 |
compinit
|
| 82 |
|
| 83 |
# colorful listings
|
| 84 |
zmodload -i zsh/complist
|
| 85 |
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
| 86 |
|
| 87 |
## case-insensitive (all),partial-word and then substring completion
|
| 88 |
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
| 89 |
|
| 90 |
# from "Writing Zsh Completion Functions" in Lunix Magazine
|
| 91 |
zstyle ':completion:*' verbose yes
|
| 92 |
zstyle ':completion:*:descriptions' format '%B%d%b'
|
| 93 |
zstyle ':completion:*:messages' format '%d'
|
| 94 |
zstyle ':completion:*:warnings' format 'No matches for: %d'
|
| 95 |
zstyle ':completion:*' group-name ''
|
| 96 |
|
| 97 |
# completion settings.
|
| 98 |
# I don't like having a horde of users, and want some specific machines for ssh
|
| 99 |
zstyle ':completion:*' hosts somehost.something.net
|
| 100 |
zstyle ':completion:*' users myuser root
|
| 101 |
|
| 102 |
export PATH="$PATH:$HOME/bin"
|
| 103 |
|
| 104 |
# ls colors
|
| 105 |
#eval `dircolors -b /etc/DIR_COLORS`
|
| 106 |
# -G works on mac and linux, but means different things
|
| 107 |
alias ls="ls -F -G"
|
| 108 |
if ls --color=auto >&/dev/null; then
|
| 109 |
# --color=auto only works on linux
|
| 110 |
alias ls="ls -F --color=auto"
|
| 111 |
fi
|
| 112 |
alias ll="ls -lah"
|
| 113 |
|
| 114 |
# directory hops
|
| 115 |
alias u='cd ..'
|
| 116 |
alias ..='cd ..'
|
| 117 |
|
| 118 |
# safety first!
|
| 119 |
alias rm="nocorrect rm -i"
|
| 120 |
alias cp="nocorrect cp -i"
|
| 121 |
alias mv="nocorrect mv -i"
|
| 122 |
alias mkdir="nocorrect mkdir"
|
| 123 |
|
| 124 |
alias du0="du -hcs"
|
| 125 |
alias du1="du -hc --max-depth 1"
|
| 126 |
alias eject="eject -v"
|
| 127 |
alias grep="grep --color=auto --exclude-dir='.svn'"
|
| 128 |
alias svnmissing="svn status | grep '^\?' | sed -e 's/\? //'"
|
| 129 |
alias svnaddmissing="svn status | grep '^\?' | sed -e 's/\? //' | xargs svn add"
|
| 130 |
alias m="make"
|
| 131 |
alias py="python"
|
| 132 |
alias vi="vim"
|
| 133 |
|
| 134 |
alias dh="ssh hulet@ideaharbor.org"
|
| 135 |
alias db="ssh b192161@hanjin.dreamhost.com"
|
| 136 |
|
| 137 |
alias mcd="sudo mount -t auto /dev/cdrom /media/cdrom"
|
| 138 |
alias ucd="sudo umount /media/cdrom"
|
| 139 |
alias musb="sudo mount -t auto -o uid=1000,noatime /dev/sda1 /media/usbdisk"
|
| 140 |
alias mmusb="sudo mount -o rw,remount /media/usbdisk" # remount as read-write
|
| 141 |
alias uusb="sudo umount /media/usbdisk"
|
| 142 |
alias ump3="sudo umount /media/SANSA\ M350"
|
| 143 |
alias passgen="head /dev/urandom | uuencode -m - | sed -ne 2p | sed -e 's/[0oOiIlL1\+\\\/]//g' | cut -c-10"
|
| 144 |
|
| 145 |
# rails
|
| 146 |
alias rdm='rake db:migrate'
|
| 147 |
alias rdm0='rake db:migrate VERSION=0'
|
| 148 |
alias rdmp='rake db:migrate RAILS_ENV=production'
|
| 149 |
alias ss='./script/server'
|
| 150 |
alias ttr='touch tmp/restart.txt' # for Passenger
|
| 151 |
|
| 152 |
# local config overrides all
|
| 153 |
if [[ -f $HOME/.zshrc.local ]]; then
|
| 154 |
source $HOME/.zshrc.local
|
| 155 |
fi
|
| 156 |
|