eval "$(dircolors -b ~/.dircolors)"

autoload -Uz compinit
compinit
zmodload -a complist
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zshcache
__git_files () {
	_wanted files expl 'local files' _files
}
zstyle :compinstall filename "$HOME/.zshrc"

HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000

setopt no_beep
setopt extendedglob
#setopt print_exit_value
setopt prompt_subst
setopt complete_in_word
setopt no_auto_menu
setopt no_always_last_prompt
setopt share_history
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt extended_history
setopt promptsubst
setopt autopushd
setopt pushdignoredups
setopt nomatch

autoload -U edit-command-line
zle -N edit-command-line
bindkey -e
bindkey '^[[3~' delete-char
bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word
bindkey '\C-v' edit-command-line
bindkey '\Ea' push-line
local WORDCHARS=${WORDCHARS//\//}\| # remove forward slash, add pipe

autoload colors
colors
bright_cyan='%{[96m%}' # not provided by colors
autoload -Uz vcs_info
zstyle ':vcs_info:*' unstagedstr "%{$fg[red]%}*"
zstyle ':vcs_info:*' stagedstr "%{$fg[red]%}+"
zstyle ':vcs_info:*' formats "$bright_cyan%b%u%c"
zstyle ':vcs_info:*' actionformats "$bright_cyan%b%u%c|%a"
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b:%r'
zstyle ':vcs_info:bzr:*' use-simple true
zstyle ':vcs_info:*' enable git hg bzr svn cvs
precmd () { vcs_info }
PROMPT="%{$fg_bold[grey]%}%* " # time
PROMPT+="%{${fg_bold[green]}%}%m%{${reset_color}%}:" # host
PROMPT+="%{${fg_bold[blue]}%}%50<...<%~%<<%{${reset_color}%} " # path
PROMPT+='${vcs_info_msg_0_} '
PROMPT+="%(?..%{$fg_bold[red]%}%? %{$reset_color%})" # exit status
PROMPT+="%1(j.%{$fg[green]%}%j .)" # suspended jobs
PROMPT+=$'%{$reset_color%} \n%(!.#.\$) '

autoload -U url-quote-magic
zle -N self-insert url-quote-magic

source $HOME/.zsh_paste

export EDITOR=vi
export MANPAGER="/bin/sh -c \"col -bx | vim -c 'set ft=man' -\""
export GREP_COLORS='ms=01;36:mc=01;31:sl=:cx=:fn=35:ln=33:bn=33:se=01;34'

alias ls='ls --color=auto -hv --group-directories-first'
alias ll='ls -l'
alias l.='ls -Ad .*'
alias la='ls -A'
alias llr='lr -1AGl -ov'
alias grep='grep --color -s'
alias df='df -hx tmpfs'
alias du='du --max-depth=1'
alias fd='fdfind'
alias sr='screen -r'
alias gip='git pull --ff-only'
alias gil='git log --graph --abbrev-commit --stat --summary -C --decorate --date=local'
alias gib='git branch -a'
alias gis='git status'
alias gid='git diff -C --date=local'
alias giw='git show -C --date=local --decorate'
alias gic='git checkout'
alias giu='git reset HEAD\^'
alias gn='git number'
alias hgw='hg diff --change .'
alias class='xprop -notype WM_CLASS'
alias tree='tree -AvL 10'
alias vi='vi -p'
alias vil='vi *(.om[1])'
alias dt='gnome-terminal --hide-menubar'
alias sudovi="sudo vi -N -u $HOME/.vimrc"
alias shrug="echo -n '¯\\(°_o)/¯' | xclip -selection clipboard"
function https() {
	openssl s_client -connect $1:443 -servername $1 < /dev/null | \
	openssl x509 -noout -text -certopt no_header,no_version,no_serial,no_signame,no_pubkey,no_sigdump
}
function cl() {
	if [ $# = 0 ]; then
		cd && ls
	else
		cd "$*" && ls
	fi
}
function pdf() {
	atril "$*" &> /dev/null &!
}

export GOPATH=$HOME/go
export PYTHONSTARTUP=$HOME/.pystartup.py
export VIRTUAL_ENV="/home/raylu/venv"

#NPM_PACKAGES="$HOME/npm-packages"
#export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"

PATH=$VIRTUAL_ENV/bin:$NPM_PACKAGES/bin:$PATH
if [ -d $HOME/bin ]; then
	PATH=$HOME/bin:$PATH
fi

if [ -x /usr/bin/fzf ]; then
	FZF_DEFAULT_OPTS='--no-mouse'
	source "/usr/share/doc/fzf/examples/key-bindings.zsh"
fi

stty stop undef
