Created
December 12, 2011 16:50
-
-
Save flixr/1468156 to your computer and use it in GitHub Desktop.
zsh config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .zshrc | |
# (copyleft) 2012 by Felix Ruess | |
# | |
# ---[ System settings ]------------------------------------------------ | |
limit -s coredumpsize 0 | |
umask 0027 | |
# ---[ ZSH Options ]---------------------------------------------------- | |
# General | |
setopt NO_BEEP CLOBBER | |
setopt MULTIOS CORRECT_ALL AUTO_CD | |
#setopt CD_ABLE_VARS | |
# does not work together nicely with menu select: | |
#setopt BASH_AUTO_LIST | |
#setopt NO_LIST_AMBIGUOUS | |
# History | |
setopt INC_APPEND_HISTORY EXTENDED_HISTORY HIST_IGNORE_DUPS HIST_FIND_NO_DUPS | |
setopt HIST_EXPIRE_DUPS_FIRST | |
#setopt SHARE_HISTORY | |
setopt HIST_REDUCE_BLANKS HIST_SAVE_NO_DUPS | |
HISTSIZE=1000 | |
SAVEHIST=1000 | |
HISTFILE=~/.zhistory | |
DIRSTACKSIZE=20 | |
# ---[ Modules ]------------------------------------------------------- | |
zmodload -i zsh/complist | |
autoload -Uz compinit | |
compinit | |
# ---[ Completition system ]------------------------------------------- | |
# If unset, the cursor is set to the end of the word if completion is | |
# started. Otherwise it stays there and completion is done from both ends. | |
# This is needed for the prefix completer | |
setopt COMPLETE_IN_WORD | |
# don't move the cursor to the end AFTER a completion was inserted | |
setopt NO_ALWAYS_TO_END | |
setopt LIST_PACKED | |
# Prevents aliases on the command line from being internally substituted before completion is attempted. | |
# The effect is to make the alias a distinct command for completion purposes. | |
#setopt COMPLETE_ALIASES | |
# turn off old compctl completion | |
#zstyle ':completion:*' use-compctl false | |
# which completers to use | |
# | |
# for use with expand-or-complete-prefix : | |
#zstyle ':completion:*' completer _complete _match _list _ignored _correct _approximate | |
# for use with expand-or-complete : | |
zstyle ':completion:*' completer _complete _match _prefix:-complete _list _correct _approximate _prefix:-approximate _ignored | |
# _list anywhere to the completers always only lists completions on first tab | |
zstyle ':completion:*:prefix-complete:*' completer _complete | |
zstyle ':completion:*:prefix-approximate:*' completer _approximate | |
# configure the match completer, more flexible of GLOB_COMPLETE | |
# with original set to only it doesn't act like a `*' was inserted at the cursor position | |
zstyle ':completion:*:match:*' original only | |
# first case insensitive completion, then case-sensitive partial-word completion, then case-insensitive partial-word completion | |
# (with -_. as possible anchors) | |
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|[-_.]=* r:|=*' 'm:{a-z}={A-Z} r:|[-_.]=* r:|=*' | |
# allow 2 erros in correct completer | |
zstyle ':completion:*:correct:*' max-errors 2 not-numeric | |
## allow one error for every three characters typed in approximate completer | |
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) numeric )' | |
# meu selection with 2 candidates or more | |
zstyle ':completion:*' menu select=2 | |
#zstyle ':completion:*' menu select=1 _complete _ignored _approximate | |
# Add colors in completions | |
eval $(dircolors) | |
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
autoload colors && colors | |
# Messages/warnings format | |
zstyle ':completion:*' verbose yes | |
zstyle ':completion:*:descriptions' format $'%{\e[01;31m%}---- %d%{\e[m%}' | |
zstyle ':completion:*:messages' format $'%{\e[01;04;31m%}---- %d%{\e[m%}' | |
zstyle ':completion:*:warnings' format $'%{\e[01;04;31m%}---- No matches for: %d%{\e[m%}' | |
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[m%}' | |
# make completions appear below the description of which listing they come from | |
zstyle ':completion:*' group-name '' | |
zstyle ':completion:*:default' select-prompt %SScrolling active: current selection at %p%s | |
## Some functions, like _apt and _dpkg, are very slow. You can use a cache in order to proxy the list of results: | |
zstyle ':completion:*' use-cache on | |
zstyle ':completion:*' cache-path ~/.zsh/cache | |
# complete man pages | |
zstyle ':completion:*:manuals' separate-sections true | |
zstyle ':completion:*:manuals.(^1*)' insert-sections true | |
# ignore uninteresting user accounts | |
zstyle ':completion:*:*:*:users' ignored-patterns \ | |
adm apache avahi avahi-autoipd backup bind bin cl-builder colord couchdb daemon dictd festival \ | |
games gdm gnats haldaemon halt hplip ident identd irc jetty junkbust kernoops libuuid lightdm \ | |
list lp mail mailnull man messagebus named news nfsnobody nobody nscd ntp operator pcap postfix \ | |
postgres proxy pulse radvd rpc rpcuser rpm rtkit saned shutdown speech-dispatcher squid sshd \ | |
statd stunnel4 sync sys syslog uucp usbmux vcsa vde2-net www-data xfs | |
# ignore uninteresting hosts | |
zstyle ':completion:*:*:*:hosts' ignored-patterns \ | |
localhost loopback ip6-localhost ip6-loopback localhost6 localhost6.localdomain6 localhost.localdomain | |
#hosts=( $(</etc/hosts) ) | |
# 1. All /etc/hosts hostnames are in autocomplete | |
# 2. If you have a comment in /etc/hosts like #%foobar.domain, | |
# then foobar.domain will show up in autocomplete! | |
#myhosts=( $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts | grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}') ) | |
#zstyle ':completion:*:(ping|mtr|ssh|scp|sftp):*' hosts $myhosts | |
#zstyle ':completion:*:(ssh|scp|sftp):*' users $users | |
# tab completion for PID :D | |
zstyle ':completion:*:*:kill:*' menu yes select | |
zstyle ':completion:*:kill:*' force-list always | |
## If you end up using a directory as argument, this will remove the trailing slash (usefull in ln): | |
#zstyle ':completion:*' squeeze-slashes true | |
## cd will never select the parent directory (e.g.: cd ../<TAB>): | |
zstyle ':completion:*:(cd|mv|cp):*' ignore-parents parent pwd | |
zstyle ':completion:*:(ls|mv|cd|chdir|pushd|popd):*' special-dirs .. | |
## ignores filenames already in the line | |
zstyle ':completion:*:(rm|kill|diff):*' ignore-line yes | |
## Ignore completion functions for commands you don't have: | |
zstyle ':completion:*:functions' ignored-patterns '_*' | |
## don't complete backup files as executables | |
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~' | |
# A newly added command will may not be found or will cause false | |
# correction attempts, if you got auto-correction set. By setting the | |
# following style, we force accept-line() to rehash, if it cannot | |
# find the first word on the command line in the $command[] hash. | |
zstyle ':acceptline:*' rehash true | |
# ---[ Window title ]-------------------------------------------------- | |
case $TERM in | |
*xterm*|rxvt|rxvt-unicode|rxvt-256color|rxvt-unicode-256color|(dt|k|E)term) | |
precmd () { print -Pn "\e]0;[%n@%M][%~]%#\a" } | |
preexec () { print -Pn "\e]0;[%n@%M][%~]%# ($1)\a" } | |
;; | |
screen) | |
precmd () { | |
print -Pn "\e]83;title \"$1\"\a" | |
print -Pn "\e]0;$TERM - (%L) [%n@%M]%# [%~]\a" | |
} | |
preexec () { | |
print -Pn "\e]83;title \"$1\"\a" | |
print -Pn "\e]0;$TERM - (%L) [%n@%M]%# [%~] ($1)\a" | |
} | |
;; | |
esac | |
# ---[ Alias Section ]------------------------------------------------- | |
alias ls='ls --color=auto' | |
alias ll='ls -lh' | |
alias la='ls -A' | |
alias l='ls -lhA' | |
alias df='df -h' | |
alias pa='ps aux' | |
alias pu='pushd' | |
alias vim='vim -c "syntax on"' | |
alias scpresume="rsync --partial --progress --rsh=ssh" | |
alias g='git' | |
# Bash alias to open Github page for project in current working directory. | |
# Will use the current active branch if it exists remotely, or falls back to master. | |
#alias github='br=$(git branch --contains HEAD | sed -rn "s/^\* //p"); if ! git ls-remote . | grep -q -e "refs/remotes/.*/${br}"; then br="master"; fi; firefox $(git config -l | sed -rn "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")' | |
# | |
# ---[ Key bindings ]-------------------------------------------------- | |
bindkey -e | |
bindkey "^[[3~" delete-char | |
bindkey '\eq' push-line-or-edit | |
bindkey '^p' history-search-backward | |
bindkey "^[[3A" history-beginning-search-backward | |
bindkey "^[[3B" history-beginning-search-forward | |
bindkey "^[[A" history-search-backward | |
bindkey "^[[B" history-search-forward | |
bindkey '^r' history-incremental-search-backward | |
bindkey -s '^B' " &\n" | |
# if prefix completer is already in list of used completers, | |
# only bind TAB to expand-or-complete instead of expand-or-complete-prefix | |
bindkey '^i' expand-or-complete # Tab | |
#bindkey '^i' expand-or-complete-prefix # Tab | |
bindkey -M menuselect '^o' accept-and-infer-next-history | |
bindkey -M menuselect '^G' send-break | |
# ---[ Terminal settings ]--------------------------------------------- | |
case "$TERM" in | |
linux) | |
bindkey '\e[1~' beginning-of-line # Home | |
bindkey '\e[4~' end-of-line # End | |
bindkey '\e[3~' delete-char # Del | |
bindkey '\e[2~' overwrite-mode # Insert | |
;; | |
# screen) | |
# # In Linux console | |
# bindkey '\e[1~' beginning-of-line # Home | |
# bindkey '\e[4~' end-of-line # End | |
# bindkey '\e[3~' delete-char # Del | |
# bindkey '\e[2~' overwrite-mode # Insert | |
# bindkey '\e[7~' beginning-of-line # home | |
# bindkey '\e[8~' end-of-line # end | |
# # In rxvt | |
# bindkey '\eOc' forward-word # ctrl cursor right | |
# bindkey '\eOd' backward-word # ctrl cursor left | |
# bindkey '\e[3~' backward-delete-char # This should not be necessary! | |
# ;; | |
rxvt*) | |
bindkey '\e[7~' beginning-of-line # home | |
bindkey '\e[8~' end-of-line # end | |
bindkey '\eOc' forward-word # ctrl cursor right | |
bindkey '\eOd' backward-word # ctrl cursor left | |
bindkey '\e[3~' backward-delete-char # This should not be necessary! | |
bindkey '\e[2~' overwrite-mode # Insert | |
;; | |
xterm*) | |
bindkey "\e[1~" beginning-of-line # Home | |
bindkey "\e[4~" end-of-line # End | |
bindkey '\e[3~' delete-char # Del | |
bindkey '\e[2~' overwrite-mode # Insert | |
;; | |
sun) | |
bindkey '\e[214z' beginning-of-line # Home | |
bindkey '\e[220z' end-of-line # End | |
bindkey '^J' delete-char # Del | |
bindkey '^H' backward-delete-char # Backspace | |
bindkey '\e[247z' overwrite-mode # Insert | |
;; | |
esac | |
# ---[ Environment ]--------------------------------------------------- | |
# set PATH so it includes user's private scripts dir if it exists | |
if [ -d ~/scripts ] ; then | |
PATH=~/scripts:"${PATH}" | |
fi | |
export CVS_RSH=ssh | |
export PAPARAZZI_HOME=/home/flixr/code/paparazzi | |
export PAPARAZZI_SRC=/home/flixr/code/paparazzi | |
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/jsbsim/lib | |
# enable the MATLAB desktop with desktop effects enabled | |
export AWT_TOOLKIT=MToolkit | |
# stuff for ROS | |
source /opt/ros/fuerte/setup.zsh | |
export ROS_PACKAGE_PATH=/home/flixr/code/xrotor/code/ros:$ROS_PACKAGE_PATH | |
#source /usr/local/share/gazebo-1.0.0/setup.sh | |
# dev stuff for building packages | |
export DEBEMAIL="[email protected]" | |
export DEBFULLNAME="Felix Ruess" | |
#export QUILT_PATCHES=debian/patches | |
# ---[ git stuff ]--------------------------------------------------- | |
# | |
# zgitinit and prompt_wunjo_setup must be somewhere in your $fpath, see https://github.com/jcorbin/zsh-git | |
setopt promptsubst | |
# Load the prompt theme system | |
autoload -U promptinit | |
promptinit | |
# Use the wunjo prompt theme | |
prompt wunjo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment