################################################################
#  PJE-0.1 桼ե륵ץ for zsh
#                       MATSUMOTO Shoji (shom@i.h.kyoto-u.ac.jp)
#                            Time-stamp: <97/09/06 20:51:37 pje>

## ʳ (󥷥Ǥʤ) ǡ
## åξ˼¹Ԥޤ

echo source .zshrc

# color-ls
#  ~/.dir_colors
if which dircolors >& /dev/null; then
  eval `dircolors -z ~/.dir_colors`
else
  export LS_OPTIONS='-F -T 0 ';
  alias ls='/bin/ls $LS_OPTIONS';
fi
export LS_OPTIONS="$LS_OPTIONS -N "
if [ "$TERM" = "dumb" ] ; then LS_OPTIONS="$LS_OPTIONS --color=no " ; fi

alias ll='ls -l'
alias la='ls -a'

# ghostview  gv Ȥ
alias ghostview=gv

# prompt 
PS1="%B%m%b:%2c%(#.#.$) "

# kterm,xterm Υȥ prompt ɽ
if [ "$TERM" = "screen" ] ; then
  SCREEN=screen@
fi
case $TERM in
kterm|xterm|screen)
    HN=$SCREEN`hostname -s`
    function termtitle () { echo "]0;$*" ; }
    function cd () { builtin cd $* ; termtitle $HN:$PWD ; }
    function popd () { builtin popd $* ; termtitle $HN:$PWD ; }
    function pushd () { builtin pushd $* ; termtitle $HN:$PWD ; }
    function pwd () { builtin pwd ; termtitle $HN:$PWD ; }
    function su () { termtitle $HN":su "$* ;
        if [ "$[1]" = "-c" ] ; then command su -c "$[2]";
        elif [ "$[2]" = "-c" ] ; then command su $[1] -c "$[3]" 
        elif [ "$[3]" = "-c" ] ; then command su - $[2] -c "$[4]"
        else command su $* ; fi
        termtitle $HN:$PWD ; }
    function rsh () {
	termtitle $HN":rsh "$*
	command rsh $* ; termtitle $HN:$PWD
    }
    function rlogin () {
	termtitle $HN":rlogin "$*
	command rlogin $*
	termtitle $HN:$PWD
    }
    function telnet () {
	termtitle $HN":telnet "$*
	command telnet $*
	termtitle $HN:$PWD
    }
    function screen () {
	command screen $*
	termtitle $HN:$PWD
    }
;;
esac

# key  (Emacs)
bindkey -e
bindkey '\C-u' backward-kill-line
bindkey '\C-w' kill-region

# zsh option
setopt correct

HISTSIZE=100
SAVEHIST=100

# stty (tty type )
stty erase ^H
stty intr ^C
stty susp ^Z
stty start undef
stty stop undef

# completion

compctl -g '*(/) *.tex' jlatex
compctl -g '*(/) *.tex' platex
compctl -g '*(/) *.tex' latex 
compctl -g '*(/) *.dvi' dvi2ps
compctl -g '*(/) *.dvi' xdvi
compctl -g '*(/) *.ps *.eps *.epsi' gv
compctl -j kill
compctl -c man
compctl -g '*(/)' cd
#for tar
compctl -f -x \
        's[--]' -k "(atime-preserve remove-files checkpoint \
                force-local ignore-failed-read preserve same-owner \
                null totals exclude use-compress-program block-compress \
                unlink help)" -X 'available options are:' - \
        'C[-1,*z*] p[2]' -g "*.tar.(Z|z|gz) *.taz *.tgz (|.)*(-/)" - \
        'C[-1,*f*] p[2]' -g "*.tar (|.)*(-/)" + -g '*' - \
        'W[1,*x*][1,*t*] p[3, -1]' -K getfilenames  -- tar gtar
# get files' name in tar file
function getfilenames () {
    local a
    read -cA a
    if [ "$curfile" != "$a[3]" ] ; then
        if [ -f $a[3] ]; then
          if [ $a[3]:e = gz -o $a[3]:e = tgz -o $a[3]:e = Z ]; then
            reply=(`tar ztf $a[3]`)
          else
            reply=(`tar tf $a[3]`)
          fi
        else
          reply=()
        fi
        curfile=$a[3]
    fi
}

