My .zshrc file
#########################################
# .zshrc
# The Z Shell config file
#########################################
# {{{ PATH #####################################################################
# Add Google Android toolset
# PATH=${PATH}:/home/cfd90/workspace/android_sdk_linux_m3-rc22a/tools
# }}}
# {{{ History ##################################################################
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory
setopt sharehistory # share history between multiple running terminals
# }}}
# {{{ Key bindings #############################################################
# REMINDER: C-V key - will print out key, for a nice reference
bindkey -e # vim sucks
# Useful piping shortcuts
bindkey -s '^|l' "|less\n" # c-| l pipe to less
bindkey -s '^|g' '|grep ""^[OD' # c-| g pipe to grep
bindkey -s '^|a' "|awk '{print $}'^[OD^[OD" # c-| a pipe to awk
bindkey -s '^|s' '|sed -e "s///g"^[OD^[OD^[OD^[OD' # c-| s pipe to sed
# Input controls
bindkey '^[[1;3D' backward-word # alt + LEFT
bindkey '^[[1;3C' forward-word # alt + RIGHT
bindkey '_^?' backward-delete-word # alt + BACKSPACE delete word backward
bindkey '^[[3;3~' delete-word # alt + DELETE delete word forward
bindkey '^[' self-insert # alt + ENTER allow multiline input
bindkey '_t' transpose-words
# }}}
# {{{ Completion ###############################################################
## Generated by compinstall
zstyle :compinstall filename '/home/cfd90/.zshrc'
autoload -Uz compinit
compinit
## End Generated by compinstall
## Taken from mako's .zshrc
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/2 )) numeric )'
# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
# seperate close errors from matches
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
## End taken from mako's .zshrc
# }}}
## {{{ Aliases #################################################################
alias grep="egrep --color=auto" # color grep output
alias ls="ls --color" # always show color
alias l="ls -lh --color" # laziness strikes again.
alias la="ls -alh --color" # list, show all, in a humane way
alias ..="cd .." # save 3 keystrokes...
alias cd..="cd .." # for annoying typos...
alias emacs="emacs -nw" # always run emacs inside the console
alias rm="rm -i" # can never be too careful...
alias diff=colordiff # pretty colors...
alias p=pwd # more lazyness...
alias c="clear;fortune rush" # another quickie
alias sr="screen -R" # attach to screen session if running
alias du="du -h" # humane treatment
alias df="df -h" # humane treatment again
alias untar="tar xzfv" # yay, less random letters to know...
alias ba="bzr add" # Bazaar shortcuts...
alias bi="bzr ignore" # ...
alias bm="bzr move" # ...
alias bd="bzr diff | colordiff" # ...yay, I see colors...
alias bk="bzr commit" # stupid, useless calculator...
alias bl="bzr log" # ...
alias bs="bzr status" # ...
alias bh="bzr help" # *phew!* End of bazaar shorcuts
alias apt-get="sudo apt-get" # remove annoyingness
alias su="su -s /bin/zsh" # make it use zsh
alias a="g '^alias' < ~/.zshrc" # QUICKKEY - alias list
alias d=dcop # QUICKKEY - dcop connections
alias h="htop -u $(whoami) -t" # QUICKKEY - system monitor
alias j=jobs # QUICKKEY - show jobs
alias k=kill # QUICKKEY - kill process
alias e=$EDITOR # QUICKKEY - edit quickly
alias m=more # QUICKKEY - yeah
alias q=exit # QUICKKEY - like vim
alias yank="dcop klipper klipper setClipboardContents" # copy - kde (klipper)
alias unyank="dcop klipper klipper getClipboardContents" # paste - kde (klipper)
# }}}
# {{{ Functions ################################################################
# yank 'a' file - kde only (klipper)
function yankf() { yank "$(cat $1)" }
# visit bash quickly
function bashorg() { lynx -dump "www.bash.org?$1" | less; }
# grabs latest .zshrc from dotfiles.org, and moves .zshrc to .zshrc.old
# backs up .zshrc.old to .zshrc.old.old just in case ;)
function updatezshrc() {
echo "Starting in 5 seconds... Ctrl+C to abort..."
sleep 5
# back up .zshrc.old just in case, only if it exists
if [[ $(file .zshrc.old) != "" ]]; then
mv .zshrc.old .zshrc.old.old
fi
# Back up .zshrc
mv .zshrc .zshrc.old
# Get new .zshrc from dotfiles.org
curl -o .zshrc http://dotfiles.org/~coder_/.zshrc
}
# }}}
# {{{ Pre-functions ############################################################
# Set title of window
function preexec() {
# When I print to the xterm title, \b doesn't seem to work, so this
# will hackily solve the problem of putting $FOOx$BAR, very ugly yes
# and there is probably a better way to do this in zsh, but I'm new to it
# also, why am I writing a comment like this to myself?
export size="$(echo \"$COLUMNS@x$LINES\" | sed s/@//g | sed s/\"//g)"
# Show screen window, or running command
if [[ "$WINDOW" == "" ]]; then
if [[ $1 != "" ]]; then
# show running command, because it doesn't stick like screen
print -Pn "\e]0;$1 - $size\a"
else
print -Pn "\e]0;zsh - $size\a"
fi
fi
}
# Show the directory in terminal title
case $TERM in
xterm*)
precmd() { preexec }
;;
esac
# }}}
# {{{ Variables ################################################################
export BZR_EMAIL="Colin Drake <codemunkey2@gmail.com>"
export BROWSER=/opt/firefox/firefox # blah, duh.... etc.
export VISUAL='emacs' # blah
export EDITOR=$VISUAL # mi editero
export BZR_EDITOR=$VISUAL # bazaar editor
export SVN_EDITOR=$VISUAL # subversion editor
export ZLS_COLORS=$LS_COLORS # show ls colors.. grr..
# }}}
# {{{ Prompt ###################################################################
# Different prompts depending on if screen is running (checks $WINDOW)
if [[ "$WINDOW" == "" ]]; then
export PS1='(%n@%m[%*]%# ' # prompt string
else
export PS1="(%n($WINDOW)@%m[%*]%# " # prompt string showing screen window
fi
export RPROMPT=' %B%~%b%)' # right side prompt string
export PS2='%_>' # basic secondary prompt
# }}}
# {{{ Misc. Options ############################################################
setopt autocd
setopt cdablevars
setopt correct # correct commands
# }}}
# {{{ Startup output ###########################################################
fortune rush
# }}}