~/.zshrc

TMOUT=30
MYPROXY="http://127.0.0.1:3128/"

#Report CPU usage for commands running longer than 10 seconds
REPORTTIME=10

TRAPALRM() {
    zle reset-prompt
}

function proxyon {
  export ftp_proxy=$MYPROXY
  export http_proxy=$MYPROXY
  export https_proxy=$MYPROXY
  export rsync_proxy=$MYPROXY
  export no_proxy="localhost,127.0.0.1,localaddress"
}

function proxyoff {
  export ftp_proxy=
  export http_proxy=
  export https_proxy=
  export rsync_proxy=
}

function showproxy {
  echo ftp_proxy=$ftp_proxy
  echo http_proxy=$http_proxy
  echo https_proxy=$https_proxy
  echo rsync_proxy=$rsync_proxy
  echo no_proxy=$no_proxy
}

function countproxy {
  local N=4
  if [ -z $ftp_proxy ]; then
    ((N=N-1))
  fi
  if [ -z $http_proxy ]; then
    ((N=N-1))
  fi
  if [ -z $https_proxy ]; then
    ((N=N-1))
  fi
  if [ -z $rsync_proxy ]; then
    ((N=N-1))
  fi
  return $N || echo -ne "P"
}

function precmd {
  #countproxy || print $?
}

bindkey '^[[1~' beginning-of-line      # Home
bindkey '^[[4~' end-of-line            # End
bindkey '^[[2~' beep                   # Insert
bindkey '^[[3~' delete-char            # Del
bindkey '^[[5~' vi-backward-blank-word # Page Up
bindkey '^[[6~' vi-forward-blank-word  # Page Down

autoload -U colors && colors
setopt prompt_subst

MYPROMPT='%F{magenta}%n%f@%F{cyan}%m%f:%K{red}$(countproxy || echo -ne P)%k %F{yellow}%}%U%~%u%f %(?,%F{green}%#,%F{red}[%?] :(%#) %f'
MYRPROMPT="[%F{yellow}%T%f]"

if [ -z $STY ]
then
  PROMPT=$MYPROMPT
  RPROMPT=$MYRPROMPT
else
  PROMPT=$MYPROMPT]
  RPROMPT=[$MYRPROMPT
fi

alias ls='ls -Fh --color'
alias ll='ls -l'
alias zz='source .zshrc'
alias viz='vi .zshrc'

setopt appendhistory inc_appendhistory
setopt AppendHistory
setopt HIST_IGNORE_DUPS
setopt TRANSIENT_RPROMPT # remove right prompt when accept cmd
setopt promptsubst # apply substitutions in prompts
setopt prompt_subst
setopt PROMPT_SUBST
setopt longlistjobs # display PID on suspend
setopt notify # report background job events immediately
setopt print_exit_value # report job status changes
setopt checkjobs # report job status on shell exit
unsetopt correct

if [ ${SHLVL} -eq 1 ]; then
    ((SHLVL+=1)); export SHLVL
    exec screen -R -t "TAB" -e "^Aa" ${SHELL} -U -l || exit

fi

#end