.zshrcメモ

# for screen
function ssh_screen(){
   eval server=\${$#}
   screen -t $server ssh "$@"
}

if [ x"$TERM" = x"screen" ]; then
   compctl -k _cache_hosts ssh_screen
   alias ssh=ssh_screen
   chpwd () { echo -n "`dirs`\" }
   preexec() {
   # see [zsh-workers:13180]
   # http://www.zsh.org/mla/workers/2000/msg03993.html
      emulate -L zsh
      local -a cmd; cmd=(${(z)2})
      case $cmd[1] in
         fg)
            if (( $#cmd == 1 )); then
                cmd=(builtin jobs -l %+)
            else
                cmd=(builtin jobs -l $cmd[2])
            fi
            ;;
         %*) 
            cmd=(builtin jobs -l $cmd[1])
            ;;
         cd)
            if (( $#cmd == 2)); then
                cmd[1]=$cmd[2]
	    fi
            ;&
         *)
            echo -n "$cmd[1]:t\"
            return
            ;;
      esac

      local -A jt; jt=(${(kv)jobtexts})

      $cmd >>(read num rest
              cmd=(${(z)${(e):-\$jt$num}})
              echo -n "^[k$cmd[1]:t^[\\") 2>/dev/null
   }
   chpwd
fi

# complete
autoload -U compinit
compinit

# prompt
autoload colors
colors
PROMPT="[%n@%m %*]$ "
SPROMPT="%{${fg[red]}%}%r%{${reset_color}%} is correct? [n,y,a,e]:% "
RPROMPT="[%{${fg[red]}%}%~%{${reset_color}%}]"

# language
export LANG=ja_JP.UFT-8

# history
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups    # ignore duplication command history
setopt share_history       # share command history data

# history search
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end

# not KY function
setopt auto_cd
setopt auto_pushd
setopt correct
setopt list_packed
setopt nolistbeep
#setopt multios
setopt noautoremoveslash
#autoload predict-on
#predict-on

# ls
export LSCOLORS=exfxcxdxbxegedabagacad
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
case "${OSTYPE}" in
freebsd*|darwin*)
  alias ls="ls -G -w"
  ;;
linux*)
  alias ls="ls --color"
  ;;
esac
zstyle ':completion:*' list-colors 'di=34' 'ln=35' 'so=32' 'ex=31' 'bd=46;34' 'cd=43;34'

# alias
setopt complete_aliases # aliased ls needs if file/dir completions work
alias where="command -v"
alias jobs="jobs -l"
alias la="ls -a"
alias lf="ls -F"
alias ll="ls -l"
alias du="du -h"
alias df="df -h"
alias su="su -l"

# personal settings
[ -f ~/.zshrc.mine ] && source ~/.zshrc.mine