zshrc
# geekounet's zshrc
# {{{ Env vars
export PATH="$HOME/.local/bin:$PATH"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export PAGER="less"
export EDITOR="vim"
export VISUAL="vim"
export LESS="-I -M -R --shift 5"
# }}}
# {{{ General settings
HISTFILE=~/.histfile
HISTSIZE=5000
SAVEHIST=5000
setopt append_history hist_ignore_all_dups hist_reduce_blanks
# Auto-cd
setopt autocd
# Disable beeps
unsetopt beep
# Disable live job notifications
unsetopt notify
# Extended globbing
setopt extendedglob
# No = expansion
unsetopt equals
# Remove RPS1 after <enter>
setopt transient_rprompt
# Color vars
autoload -U colors
colors
# Watch for login/logout
watch=all
# Smart completion
zstyle :compinstall filename "$HOME/.zshrc"
autoload -Uz compinit
compinit
# }}}
# {{{ Keybindings
# vi keybindings
bindkey -v
# URxvt keys
bindkey '[2~' overwrite-mode
bindkey '[3~' delete-char
bindkey '[7~' beginning-of-line
bindkey '[8~' end-of-line
bindkey '[5~' history-search-backward
bindkey '[6~' history-search-forward
# Man
bindkey '^X^H' run-help
# Edit cmdline
autoload edit-command-line
zle -N edit-command-line
bindkey '^xe' edit-command-line
# Complete help
bindkey '^xc' _complete_help
# () [] {} ...
bindkey -s '((' '()\ei'
bindkey -s '( (' '( )\ehhi'
bindkey -s '(((' '(\ea( ))\ehhhi'
bindkey -s '{{' '{}\ei'
bindkey -s '{ {' '{ }\ehi'
bindkey -s '{{{' '{\ea{ }}\ehhhi' # }}} (quick and ugly folding fix...)
bindkey -s '[[' '[]\ei'
bindkey -s '[ [' '[ ]\ehhi'
bindkey -s '[[[' '[\ea[ ]]\ehhhi'
bindkey -s "''" "'\ea'\ei"
bindkey -s '""' '"\ea"\ei'
# }}}
# {{{ Per OS settings
case `uname -s` in
FreeBSD)
[[ $TERM == "rxvt-unicode" ]] && export TERM="xterm"
export LSCOLORS="exgxfxcxcxdxdxhbadacec"
alias ls="ls -G"
;;
Linux)
if [[ -r ~/.dir_colors ]]; then
eval `dircolors -b ~/.dir_colors`
elif [[ -r /etc/DIR_COLORS ]]; then
eval `dircolors -b /etc/DIR_COLORS`
fi
# Colored completion
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
alias ls="ls --color=auto"
alias cal="cal -m"
which bsdtar >/dev/null && alias tar="bsdtar"
;;
esac
# }}}
# {{{ Per host settings
case ${HOST%%.*} in
Corellia)
export MAILDIR="~/.maildir"
alias sirc="screen -DRAa -S irssi"
alias smutt="screen -DRAa -S mutt"
[[ $UID != 0 ]] && umask 0027
;;
Korriban)
alias sr="screen -DRAa -S rails"
alias sd="screen -DRAa -S dev"
alias st="screen -DRAa -S rtorrent"
# alias snes9x="snes9x -stereo -r7 -y2"
# alias osnes9x="osnes9x -stereo -r7 -y5"
;;
esac
# }}}
# {{{ General aliases
alias :e="\$EDITOR"
alias :q="exit"
alias l="ls -A -F"
alias ll="ls -h -l "
alias la="ls -a"
alias grep="grep --color=auto"
alias sm="screen -DRAa -S main"
# }}}
# {{{ Prompts
# Right prompt with clock
RPS1=" %{$fg_bold[black]%}%D{%d/%m/%y %H:%M:%S}%{${reset_color}%}"
# Others prompts
PS2="%{$fg_no_bold[yellow]%}%_>%{${reset_color}%} "
PS3="%{$fg_no_bold[yellow]%}?#%{${reset_color}%} "
# }}}
# {{{ title()
# Display the title, and append the command if given in $1
function title {
t="%n@%m %~"
case $TERM in
screen)
print -nP "\ek$t\e\\"
print -nP "\e]0;$t\a"
;;
xterm*|rxvt*|(E|e)term)
print -nP "\e]0;$t\a"
;;
esac
}
# }}}
# {{{ precmd()
function precmd {
title
local deco="%{${fg_bold[black]}%}"
if [[ -O "$PWD" ]]; then
local path_color="${fg_no_bold[white]}"
elif [[ -w "$PWD" ]]; then
local path_color="${fg_no_bold[blue]}"
else
local path_color="${fg_no_bold[red]}"
fi
case ${HOST%%.*} in
Corellia) local host_color="${fg_bold[cyan]}" ;;
Endor) local host_color="${fg_bold[green]}" ;;
Korriban) local host_color="${fg_bold[yellow]}" ;;
Kohlma) local host_color="${fg_bold[blue]}" ;;
*) local host_color="${fg_bold[default]}" ;;
esac
local return_code="%(?..${deco}!%{${fg_no_bold[red]}%}%?${deco}! )"
local user_at_host="%{${fg_bold[default]}%}%n${deco}@%{${host_color}%}%m"
local cwd="%{${path_color}%}%48<...<%~"
local sign="%(!.%{${fg_bold[red]}%}.${deco})%#"
PS1="${return_code}${deco}[${user_at_host} ${cwd}${deco}] ${sign}%{${reset_color}%} "
}
# }}}
# vim:filetype=zsh:tabstop=8:shiftwidth=2:fdm=marker: