ZDOTDIR=~/.zsh
zstyle :compinstall filename $ZDOTDIR/.zshrc
autoload -U compinit
compinit -d $ZDOTDIR/.zcompdump
HISTFILE=~/.histfile
LISTMAX=200
HISTSIZE=2000
SAVEHIST=2000
export TMPPREFIX=$ZDOTDIR/tmp
export HISTFILE=$ZDOTDIR/zsh_history
[ -d "$ZDOTDIR" ] || {
echo "Creating .zsh dir in '$ZDOTDIR'";
mkdir "$ZDOTDIR"
}
[ -d "$TMPPREFIX" ] || {
echo "Creating tmp dir in '$TMPPREFIX'";
mkdir "$TMPPREFIX"
}
#PROXY
#if [ `hostname` = "underground" ]; then
# export HTTP_PROXY=http://localhost:xxxx
#else
# export HTTP_PROXY=http://proxy.lan:xxxx
#fi
#export FTP_PROXY=$HTTP_PROXY
#export http_proxy=$HTTP_PROXY
#export ftp_proxy=$HTTP_PROXY
#PROXY
setopt AlwaysLastPrompt # try to return to the last prompt if given no numeric argument.
setopt AppendHistory # zsh sessions will append their history list to the history file, rather than overwrite it.
setopt AutoMenu # Automatically use menu completion after the second consecutive request for completion.
setopt Beep # Beep on error in ZLE.
setopt NoHup # NO send the HUP signal to running jobs when the shell exits.
setopt Equals # Perform = filename expansion.
setopt ExtendedHistory # Save each command's beginning timestamp
setopt FunctionArgzero # When executing a shell function or sourcing a script, set $0 temporarily to the name of the function/script.
setopt HistBeep # Beep when an attempt is made to access a history entry which isn't there.
setopt HistIgnoreDups # Do not enter command lines into the history list if they are duplicates of the previous event.
setopt HistIgnoreSpace # Remove command lines from the history list when the first character on the line is a space.
setopt LongListJobs # List jobs in the long format by default.
setopt ListTypes # When listing files that are possible completions, show the type of each file with a trailing identifying mark.
setopt MailWarning # Print a warning message if a mail file has been accessed since the shell last checked.
setopt MultIOs # Perform implicit tees or cats when multiple redirections are attempted
setopt PrintEightBit # Print eight bit characters literally in completion lists
setopt RmStarSilent # Do not query the user before executing `rm *' or `rm path/*'.
setopt ShortLoops # Allow the short forms of for, select, if, and function constructs.
COMM_PATH="/usr/local/mysql/bin:/usr/local/pgsql/bin"
COMM_MAN="/usr/local/pgsql/man:/usr/local/mysql/man"
export PATH="/usr/xpg6/bin:/usr/xpg4/bin:/usr/ucb:/bin:/sbin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/sfw/sbin:/usr/local/bin:/usr/local/sbin:/usr/sfw/i386-sun-solaris2.10/bin:/opt/SUNWspro/bin:/usr/ccs/bin"
#Systems specials
host_os=`uname|tr '[:upper:]' '[:lower:]'`
case $host_os in
linux)
unsetopt HIST_SAVE_BY_COPY
alias ls="ls -F --color=auto"
export PATH="$COMM_PATH:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/bin:/bin"
export MANPATH="$COMM_MAN:/usr/share/man:/usr/share/openssl/man:/usr/local/man"
#[ `grep -V | grep 'GNU.*grep' | sed 's/[^0-9\.]//g' | perl -e "if ( <STDIN>-2.5 >= 0 ) { print \"yes\n\"; } else { print \"no\n\";}"` = "yes" ] && export GREP_OPTIONS='--color=auto'
[ "`grep --help 2>&1|grep -- '--color'`" ] && export GREP_OPTIONS='--color=auto'
eval `dircolors`
export LANG=ru_RU.UTF-8
;;
freebsd|dragonfly)
export PATH="$COMM_PATH:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/bin:/bin"
export MANPATH="$COMM_MAN:/usr/share/man:/usr/share/openssl/man:/usr/local/man"
#[ `grep -V | grep 'GNU.*grep' | sed 's/[^0-9\.]//g' | perl -e "if ( <STDIN>-2.5 >= 0 ) { print \"yes\n\"; } else { print \"no\n\";}"` = "yes" ] && export GREP_OPTIONS='--color=auto'
[ "`grep --help 2>&1|grep -- '--color'`" ] && export GREP_OPTIONS='--color=auto'
export LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:\
*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:\
*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:\
*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:";
export CLICOLOR=
unsetopt HIST_SAVE_BY_COPY
export LANG=ru_RU.UTF-8
;;
openbsd|netbsd)
alias ls="$ls -xCF"
[ $TERM = "xterm" ] && export TERM=rxvt
;;
sunos)
[ $TERM = "xterm" ] && export TERM=at386
alias ls="$ls -xCF"
alias chown=/bin/chown
export PATH="$COMM_PATH:/usr/local/bin:/usr/local/sbin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/ucb:/bin:/sbin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/sfw/sbin:/usr/sfw/i386-sun-solaris2.10/bin:/opt/SUNWspro/bin:/usr/ccs/bin"
export MANPATH="$COMM_MAN:/usr/share/man:/usr/share/openssl/man:/usr/local/man"
export LC_ALL=ru_RU.UTF-8
export LANG=ru_RU.UTF-8
;;
* )
alias ls="$ls -xCF"
;;
esac
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
#Systems specials
export JAVA_HOME=/usr/java
export ANT_HOME=/usr/local/ant
#EDITOR
for PROG in vim vi
do
CHECK_ED=`which $PROG`
if [ -x $CHECK_ED ]; then
EDITOR=$CHECK_ED
export EDITOR
export S_CLEDITOR=$EDITOR
export VISUAL=$EDITOR
break
fi
done
#EDITOR
#less colors
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
#less colors
export PAGER=less
#Hosts specials
host_host=$(hostname|tr '[:upper:]' '[:lower:]');
case $host_host in
domas-lt)
export PATH=$PATH:/opt/kde3/bin
unset http_proxy ftp_proxy HTTP_PROXY FTP_PROXY
;;
xxx)
export PATH=$PATH:/opt/kde3/bin
unset http_proxy ftp_proxy HTTP_PROXY FTP_PROXY
;;
underground)
export TOOLS_HOME=~/tools
export MAVEN_HOME=/usr/local/maven-2.0.6
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
;;
napoli)
export JAVA_HOME=/usr/local
export ANT_HOME=$JAVA_HOME
;;
salerno)
export JAVA_HOME=/usr/local
export ANT_HOME=$JAVA_HOME
;;
esac
#Hosts specials
#Users specials
username=$(whoami|/usr/bin/tr '[:upper:]' '[:lower:]');
[ -z $SUDO_USER ] || { username=$SUDO_USER }
case $username in
domas|andrey)
export PATH=~/.cw/def:$PATH
export LSCOLORS=Ea
bindkey -v
alias h=history
alias df='df -h'
alias less='less -M'
alias gzless='LESSOPEN="|gzip -cdfq %s" less'
alias bzless='LESSOPEN="|bunzip2 -cdfq %s" less'
alias ispell='ispell -d russian'
alias ll='ls -l'
alias la='ls -A'
alias li='ls -ial'
alias lsd='ls -ld *(-/DN)'
alias lsa='ls -ld .*'
alias -g M='|more'
alias -g L='|less'
alias -g H='|head'
alias -g T='|tail'
alias tailmsg='tail -f /var/log/messages'
alias tailmail='tail -f /var/log/maillog'
alias -g N='2>/dev/null'
alias -g cfg='cfg'
setopt HIST_REDUCE_BLANKS
setopt TRANSIENT_RPROMPT
setopt notify globdots pushdtohome cdablevars autolist
setopt autocd recexact
setopt autoresume pushdsilent noclobber
setopt autopushd pushdminus extendedglob rcquotes
unsetopt bgnice autoparamslash
setopt No_Beep
cfg() { scp -r ~/.zshrc ~/.vimrc ~/.vim $1:~/ }
setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility
freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
fpath=($fpath ~/.zfunc)
for func in $^fpath/*(N-.x:t); autoload $func
typeset -U path cdpath fpath manpath
zmodload -a zsh/stat stat
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile
function precmd {
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
###
# Truncate the path if it's too long.
PR_FILLBAR=""
PR_PWDLEN=""
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
local pwdsize=${#${(%):-%~}}
if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
((PR_PWDLEN=$TERMWIDTH - $promptsize))
else
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
fi
}
setopt extended_glob
preexec () {
if [[ "$TERM" == "screen" ]]; then
local CMD=${1[(wr)^(*=*|sudo|-*)]}
echo -n "\ek$CMD\e\\"
fi
}
setprompt () {
###
# Need this so the prompt will work.
setopt prompt_subst
###
# See if we can use colors.
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
###
# See if we can use extended characters to look nicer.
typeset -A altchar
set -A altchar ${(s..)terminfo[acsc]}
PR_SET_CHARSET="%{$terminfo[enacs]%}"
PR_SHIFT_IN="%{$terminfo[smacs]%}"
PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
PR_OPEN="["
PR_CLOSE="]"
###
# Decide if we need to set titlebar text.
case $TERM in
xterm*|rxvt*|at386)
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
;;
screen)
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
;;
*)
PR_TITLEBAR=''
;;
esac
###
# Decide whether to set a screen title
if [[ "$TERM" == "screen" ]]; then
PR_STITLE=$'%{\ekzsh\e\\%}'
else
PR_STITLE=''
fi
###
# Finally, the prompt.
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}$PR_BLUE$PR_SHIFT_IN$PR_SHIFT_OUT$PR_OPEN$PR_GREEN%(!.%SROOT%s.%n)$PR_BLUE@$PR_GREEN%m$PR_BLUE:$PR_MAGENTA%$PR_PWDLEN<...<%~%<<$PR_BLUE$PR_CLOSE%(!.$PR_RED.$PR_WHITE)%#$PR_NO_COLOUR '
RPROMPT=' $PR_BLUE$PR_SHIFT_OUT(%(?..$PR_LIGHT_RED%?$PR_BLUE:)$PR_YELLOW%D{%H:%M}$PR_BLUE)$PR_NO_COLOUR '
PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT($PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
}
setprompt
;;
esac
#Users specials