# Sec's famous .zshenv  ,last modified: 11.04.97 
# Reduzierte version fuer den sysad-kurs an der BOS.
# vim:set ts=4 ai:

# tty auf 8 bit clean einstellen
tty >/dev/null 2>&1 && stty erase ^H cs8 -istrip

# Pfad setzen - geeignet fuer sysads :)
path=(~/bin /usr/local/bin /usr/bin /bin /usr/X11R6/bin /usr/games /sbin /usr/sbin /usr/local/sbin /usr/libexec)

# wenn vorhanden dann lieber vim & less statt vi & more
[ -x /usr/local/bin/less ] && export PAGER=/usr/local/bin/less
[ -x /usr/local/bin/vim ] && export EDITOR=/usr/local/bin/vim && alias vi='vim'

export BLOCKSIZE=K											# du in 1K-bloecken
export LESSCHARSET=latin1									# ich will umlaute
export LC_CTYPE=ISO_8859-1
export MM_NOASK=text,text/us-ascii,message/delivery-status	# fuer metamail
export MM_CHARSET=iso-8859-1
export PGPPATH=~/.pgp/										# fuer pgp
export NNTPSERVER=news										# newsserver
export TOP=-I												# fuer top
export USA_RESIDENT=NO

# Display bei rlogin richtig setzen:
if [ "$TERM" = "xterm" -a -z "$DISPLAY" ] ; then
  export DISPLAY=`who am i | sed -e 's/.*(//' -e 's/[):].*//'`:0.0
  echo DISPLAY set to $DISPLAY
fi


# ZSH - OPTIONS
bindkey -e
bindkey '^i' expand-or-complete-prefix
bindkey '^[#' pound-insert
bindkey '[A' up-line-or-search
bindkey '[B' down-line-or-search
PROMPT=%_%m:%~%(#.#.\>)
PROMPT2=\(%3_\)%(#.#.\>)
PROMPT3=\(%3_\)\?
setopt INTERACTIVE_COMMENTS NO_HUP 
setopt CDABLE_VARS AUTO_NAME_DIRS
setopt HIST_IGNORE_DUPS HIST_NO_STORE APPEND_HISTORY EXTENDED_HISTORY
# Einstellungen fuer completion
setopt LIST_TYPES LIST_AMBIGUOUS AUTO_LIST NO_LIST_BEEP

#weitere zsh-eistellungen
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'	# fuer completion
NULLCMD=:
READNULLCMD=less
SAVEHIST=1000 					# History der alten befehle
HISTFILE=~/.zhist
watch=(notme)                   # watch for everybody but me
LOGCHECK=60                     # check every 1 min for login/logout activity
WATCHFMT='%n %a %l from %m at %T.'
MAILCHECK=300


# Dos Feeling, oder die elegante art Tippfehler zu vermeiden.
alias dir='ls -alFo'
alias type='cat'
alias cls='clear'
alias cd..='cd ..'
alias del='rm'
alias edit='vi'
alias md='mkdir'
alias rd='rmdir'


# Wenn man tippfaul ist, bevorzugt man vielleicht auch:
ns () { netscape $* & }
alias f='finger'
alias rs='eval `resize`'
alias j='jobs -l'
alias !='which'
alias m='time idprio 10 nice -1 make'		# Make im 'hintergrund'
ff () { find -xdev . -name $* -print }		# FileFind, besser 'locate'
alias psg p
alias ..='cd ..'
alias xl='xlock -install -mode random'		# Bildschirm-lock


# Alles zum Dateien-listen
alias ll='ls -lF'
alias l=ll
alias l.='ll *(.)'				# Alle normalen Dateien (keine directorys)
la () { ls -ld $**(R) }			# Alle world-readable Files
llsize () { ll $*|sort +4 }		# Nach der groesse sortiert


# Die trickrechen Spezial-Aliase ;-)
xn () { echo -n ^[]2\;$* ^G } 					# Setze Xterm-Titel
p() { ps auxwww| awk "NR==1;/${*:-$USER}/" }	# Alle Prozesse die mir gehoeren
alias xyzzy='echo Nothing happens.'
setenv() { export $1=$2 }  # csh compatibility


# Ein paar einfachere completions

function makecomp() {
	reply=(`sed -n "/^[^#     ]*:\$/s/:\$//p"<Makefile`)
}
compctl -K makecomp make
compctl -c man
compctl -g "*.dvi" + -g '*(D-/)' xdvi
compctl -g "*.tex" + -g '*(D-/)' latex
compctl -g '*.(e|)ps' + -g '*(-/)' gs ghostview

compctl -g '*(D-/)' cd
compctl -g '*(D/)' rmdir
compctl -l '' sudo screen time nohup exec nice
compctl -z -P '%' bg
compctl -j -P '%' fg jobs disown
compctl -caF type whence which
compctl -l '' -x 'p[1]' -f -- . source
compctl -b bindkey

# kill takes signal names as the first argument after -, but job names after %
# or PIDs as a last resort
compctl -j -P '%' + -s '`ps -x | tail +2 | cut -c1-5`' + \
    -x 's[-] p[1]' -k "($signals[1,-3])" -- kill

