# $Author: Mihai Şucan $ # $URL: http://www.robodesign.ro $ # $Date: 2008-11-05 13:25:36 +0200 $ # Options # ======= # cd_able_vars setopt \ auto_cd \ auto_pushd \ no_bg_nice \ correct \ correct_all \ extended_history \ inc_append_history \ path_dirs \ pushd_ignore_dups \ pushd_minus \ pushd_silent \ share_history \ hist_ignore_dups # Environment variables # ===================== HISTFILE=~/.histfile.zsh HISTSIZE=1000 SAVEHIST=1000 # username@host:folder PROMPT="%n@%m:%c%# " RPROMPT=" %T" export EDITOR=vim export VISUAL=vim # set PATH so it includes user's private bin if it exists if [ -d ~/bin ]; then export PATH=~/bin:"${PATH}" fi # do the same with MANPATH if [ -d ~/man ]; then export MANPATH=~/man:"${MANPATH}" fi LOGCHECK=60 # seconds WATCHFMT="[%B%D %T%b] %B%n%b has %a %B%l%b from %B%M%b" WATCH='all' # Zstyles (completion) # ==================== zstyle ':completion:*' auto-description 'specify: %d' zstyle ':completion:*' completer _expand _complete _match _correct _approximate _prefix _history zstyle ':completion:*' completions 1 zstyle ':completion:*' file-sort name zstyle ':completion:*' format 'Completing %B%d%b' zstyle ':completion:*' glob 1 zstyle ':completion:*' group-name '' #zstyle ':completion:*' ignore-parents parent pwd zstyle ':completion:*' expand prefix suffix zstyle ':completion:*' squeeze-slashes true zstyle ':completion:*' list-colors '' zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s zstyle ':completion:*' match-original both zstyle ':completion:*' max-errors 2 zstyle ':completion:*' menu select=1 zstyle ':completion:*' prompt '%B%e%b errors found' zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s zstyle ':completion:*' substitute 1 zstyle ':completion:*' verbose true # f-1.j would complete to foo-123.jpeg zstyle ':completion:*:complete:*' matcher 'r:|[._-]=* r:|=*' # Separate matches into groups zstyle ':completion:*:matches' group true # Describe each match group. zstyle ':completion:*:descriptions' format "---- %d" # Messages/warnings format zstyle ':completion:*:messages' format '-- %d' zstyle ':completion:*:warnings' format 'No match for: %B%d%b' # Describe options in full zstyle ':completion:*' description true zstyle ':completion:*:*:kill:*' command 'ps -eo pid,user,time,comm -u$USER' zstyle ':completion:*:*:killall:*' command 'ps -eo comm -u$USER' zstyle :compinstall filename "${HOME}/.zshrc" autoload -Uz compinit compinit # Aliases # ======= alias -r cls='clear' alias -r shutdown='sudo shutdown' alias -r ls='ls -F --color' alias -r d='dirs -v' alias -r dir='ls' alias -r ..='cd ..' alias -r ...='cd ..' alias -r cd..='cd ..' alias -r cd...='cd ..' alias -r cd/='cd /' alias -r -1='cd -1' alias -r -2='cd -2' alias -r -3='cd -3' alias -r -4='cd -4' alias -r -5='cd -5' alias -r -6='cd -6' alias -r -7='cd -7' alias -r -8='cd -8' alias -r -9='cd -9' alias -r 1='cd +2' alias -r 2='cd +2' alias -r 3='cd +3' alias -r 4='cd +4' alias -r 5='cd +5' alias -r 6='cd +6' alias -r 7='cd +7' alias -r 8='cd +8' alias -r 9='cd +9' # Nice trick from zshwiki.org. # If "cd /path/to/file", then cd will simply go to "/path/to" (eliminating the file name). cd () { if (( $# != 1 )); then builtin cd "$@" return fi if [[ -f "$1" ]]; then builtin cd "$1:h" else builtin cd "$1" fi } # Keys # ==== bindkey -v bindkey '[1~' vi-beginning-of-line bindkey '[4~' vi-end-of-line bindkey 'OH' vi-beginning-of-line bindkey 'OF' vi-end-of-line #bindkey -M vicmd '.' insert-last-word bindkey -M vicmd 'u' undo bindkey -M vicmd '' redo bindkey -M viins '' history-incremental-search-backward bindkey -M viins '' history-incremental-search-forward bindkey -M viins '[3~' vi-delete-char # Terminal title # ============== function my_title { if [[ $TERM == "screen" ]]; then # Use these two for GNU Screen: print -nR $'\033k'$1$'\033'\\\ print -nR $'\033]0;'$2$'\a' elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then # Use this one instead for XTerms: print -nR $'\033]0;'$*$'\a' fi } # This function sets the correct terminal title. # Additionally it runs command-not-found, if needed, like bash does in Ubuntu installations. function precmd { local last_exit=$? local folder="${PWD/$HOME/~}" local folder2=$folder:t if [[ "$folder" == "/${folder2}" ]]; then folder2="/${folder2}" fi my_title "${USER}@${HOST}:${folder2}" local cnf="/usr/lib/command-not-found" if [[ $last_exit -eq 127 && -x "$cnf" ]]; then emulate -L zsh local -a cmd; cmd=(${(z)history[$((HISTCMD-1))]}) cmd=$cmd[1]:t if [[ -z "${commands[$cmd]}" ]]; then python "$cnf" -- $cmd return $? fi fi return $last_exit } function preexec { emulate -L zsh local -a cmd; cmd=(${(z)1}) my_title "${USER}@${HOST}:" $cmd[1]:t "$cmd[2,-1]" } # vim:set ts=4 sw=4 sts=4 sta noet fenc=utf-8 ff=unix: