Source

dotfiles / zshrc

# Make sure the profile gets loaded first
source ~/.profile

# http://people.debian.org/~falk/zshrc

setopt interactivecomments

PROMPT=$'%{\e[0;32m%}[%{\e[0;31m%}%n%{\e[0;32m%}@%{\e[0;34m%}%m%{\e[0;32m%}]%{\e[0;33m%} %~%b '

HISTFILE=~/.zsh_history
HISTSIZE=200
SAVEHIST=1000

setopt append_history
setopt auto_cd
setopt autopushd
setopt correct
setopt extended_glob
setopt histignoredups
setopt interactive_comments
setopt list_packed		# Okay to set different column-widths when completing
setopt no_bg_nice
setopt no_hup
setopt no_banghist		# ! is not special
setopt no_clobber		# Don't allow redirections overwrites [DUPENV]
setopt print_eight_bit          # Print 8-bit in completions


# bindkey '^[[1~' beginning-of-line
# bindkey '^[[4~' end-of-line

bindkey "^[[3~"   delete-char		# xterm
bindkey "^[[1~"   beginning-of-line	# Linux console
bindkey "^[OH"    beginning-of-line	# xterm
bindkey "^[[H"    beginning-of-line	# xterm
bindkey "^[[4~"   end-of-line		# Linux console
bindkey "^[OF"    end-of-line		# xterm
bindkey "^[[F"    end-of-line		# xterm
bindkey "^[[5D"   backward-word		# xterm
bindkey "^[[5C"   forward-word		# xterm
bindkey "^[[1;5D" backward-word		# xterm XFree86 4.3
bindkey "^[[1;5C" forward-word		# xterm XFree86 4.3
bindkey "^[O5D"   backward-word		# screen
bindkey "^[O5C"   forward-word		# screen

#bindkey '^[OD' backward-word
#bindkey '^H' backward-word
#bindkey '^[OC' forward-word
#bindkey '^L' forward-word

bindkey '^[[3~' delete-char

bindkey '\e[2~' overwrite-mode
bindkey '\e[5~' beginning-of-buffer-or-history
bindkey '\e[6~' end-of-buffer-or-history

bindkey '^R' history-incremental-search-backward

bindkey '^[[A' up-line-or-history 
bindkey '^[[B' down-line-or-history 

stty eof '^D'

# we want colorful listings
zmodload -i zsh/complist
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}

autoload -U compinit
compinit


if [[ "$TERM" == screen ]] then
  # Set screen's window title to the command the user typed.
  preexec() { print -n '\ek'$1'\e\\' }
  # Restore a generic title if no program is running.
  
  precmd() { print -n '\ek'$HOST:$PWD'\e\\' }
    fi

# set title in xterm; works also in many other terminals
xterm-title () {
  case $TERM in
    xterm*|rxvt)
      iconname="$2"
      if [[ "$iconname" == "" ]] then
        iconname="$1"
      fi
      print -Pn "\e]2;$1\a\e]1;$iconname\a"
    ;;
  esac
}

chpwd() {
    [[ -t 1 ]] || return		# no terminal as output?
        case $TERM in
	    sun-cmd)			# never really tried this
	          print -Pn "\e]l%~\e\\"
		        ;;
        *xterm*|rxvt|(dt|k|E)term)
	        # cute hack to add a unique number to all xterm titles
#      if [[ -d /dev/pts ]] then
#	xterm-title "$(print -Pn "[${TTY#/dev/pts/}] %n@%M:%~")" \
#		    "$(print -Pn "[${TTY#/dev/pts/}] %M:%~")"
#      else
	  	xterm-title "$(print -Pn "%n@%M:%~")" "$(print -Pn "%M:%~")"
#      fi
		      ;;
	  esac
}
chpwd


man () {
    xterm-title "man $*"
    command man $*
	chpwd
}

less () {
    xterm-title "$*"
    command less $*
	chpwd
}

make () {
    xterm-title "make $*..."
    command make $*
    local retval=$?
    chpwd
    return retval
}


alias mv='nocorrect mv'       # no spelling correction on mv
alias cp='nocorrect cp'
alias mkdir='nocorrect mkdir'

di() { export DISPLAY=${1:-:0} }
pc() { awk "{print \$$1}" }
rot13 () { tr "[a-m][n-z][A-M][N-Z]" "[n-z][a-m][N-Z][A-M]" }

set -o emacs