I've been thinking about this for a while, but I was waiting to have a sufficiently nice ZSH configuration to publish it. After today's mishap (running rm -Rf * in the root directory), I decided to finish it quickly. So here's my configuration which can still be optimized, but is already very good for everyday use :-).
It works on Linux, Mac, BSD, and Windows (Cygwin).
The content of the files below may not be completely up-to-date. If you want my latest ZSH configuration, here's my git repository address: https://www.deimos.fr/gitweb
Installation
If you don't have ZSH installed, install it in the simplest way possible. On Debian for example:
#!/bin/zsh# Version detectionZSH_VERSION_TYPE=old
if[[$ZSH_VERSION==3.1.<6->*||$ZSH_VERSION==3.2.<->*||$ZSH_VERSION==4.<->*]];thenifwhichzstyle>/dev/null;thenZSH_VERSION_TYPE=new
fifi# Uname systemexportMYSYSTEM=`uname`# If you don't want history enter 1# Do not forget to delete ~/.zshhistoryexportNOHIST="0"# Using environnement filesforenvfilein~/.zsh/*;dotest-f$envfile&&source$envfiledone# Default Umaskumask022# Make default colorif[-z"$nocolor"];thenc6&&c2;elsePS1="%n@%m %~ %% "exportPS1fi
#!/bin/zsh## Check if we are using Cygwin ##if[`uname`="CYGWIN*"];thenexportTERM=cygwin
elseexportTERM=xterm-color
fiusernames=($(cut-d:-f1/etc/passwd))groups=($(cut-d:-f1/etc/group))case"$TERM"inxterm*|rxvt|linux|cygwin);;*)nocolor=yes
;;esac# Set localesif[$MYSYSTEM="SunOS"];thenexportLANGUAGE=fr_FR.ISO8859-15
exportLC_ALL=fr_FR.ISO8859-15
exportLANG=fr_FR.ISO8859-15
elseexportLANGUAGE=fr_FR.UTF8
exportLC_ALL=fr_FR.UTF8
exportLANG=fr_FR.UTF8
fiexportLESSCHARSET=latin9
exportMINICOM="-c on"exportLESS="-S -g"exportJAVA_HOME="/usr/lib/jvm/cacao/"LOGCHECK=60WATCHFMT="%n has %a %l from %M"# CVSexportCVS_RSH=/usr/bin/ssh
exportCVSROOT=:ext:user@host:/var/lib/cvs
# HistoryexportHISTSIZE=5000exportHISTFILE=$HOME/.zshhistory
if[$NOHIST="1"];thenexportSAVEHIST=0elseexportSAVEHIST=$HISTSIZEfi# Defaut editorexportEDITOR=vim
exportLISTMAX=0# Use most if possibleif[[-x/usr/bin/most||-x/opt/local/bin/most]];thenexportPAGER=most
elseexportPAGER=more
fiexportBLOCK_SIZE=human-readable
exportLS_COLORS='no=00:fi=00:di=0;34:ln=01;36:pi=40;33:so=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:*.rar=01,31:*.par2=01,31:*.deb=01;31:*.rpm=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.pgm=01;35:*.pbm=01;35:*.ppm=01;35:*.tga=01;35:*.png=01;35:*.GIF=01;35:*.JPG=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=00;35:*.gl=01;37:*.dl=01;37:*.mly=01;37:*.mll=01;37:*.mli=01;37:*.ml=01;37:*.cpp=01;37:*.cc=01;37:*.c=01;37:*.hh=01;37:*.h=01;37:*Makefile=4;32:*.pl=4;32:*.sh=4;32:*.ps=01;34:*.pdf=01;34:*TODO=01;37:*TOGO=01;37:*README=01;37:*LINKS=01;37:*.y=01;37:*.l=01;37:*.algo=01;37'limitcore0
#!/bin/zshsetconvert-metaoff# Don't strip high bit when reading or displaying. setinput-metaonsetoutput-metaon
setappendhistory# multiple parallel zsh sessions will all have their history lists added to the history# No bipsunsetoptbeep
unsetopthist_beep
unsetoptlist_beep
unsetoptignore_eof# Logout Ctrl+Dsetoptchase_links# Properly handle symbolic linkssetopthist_verify# Don't execute command when searching history with !setoptauto_list
setoptauto_cd# If command is invalid but matches a subdirectory name, execute 'cd subdirectory'setoptauto_remove_slash# When last character of completion is '/' and space is typed after, the '/' is deletedfunctioncommon_terms(){bindkey"\e[2~"quoted-insertbindkey"\e[3~"delete-charbindkey"\e[5~"beginning-of-historybindkey"\e[6~"end-of-history}# Make the Home, End, and Delete keys work on common terminals. if[["$TERM"=="linux"]];thencommon_termsbindkey"\e[1~"beginning-of-linebindkey"\e[4~"end-of-lineelif[["$TERM"=="rxvt"]];thencommon_termsbindkey"\e[7~"beginning-of-linebindkey"\e[8~"end-of-lineelif[["$TERM"==xterm*]];thencommon_termsbindkey"\e[1~"beginning-of-line
bindkey"\e[4~"end-of-linefibindkey-s'^X^Z''%-^M'bindkey'^[e'expand-cmd-path
bindkey-s'^X?''\eb=\ef\C-x*'bindkey'^[^I'reverse-menu-complete
bindkey'^[p'history-beginning-search-backwardbindkey'^[n'history-beginning-search-forwardbindkey'^W'kill-regionbindkey'^I'expand-or-complete-prefixbindkey-s'^[[Z''\t'bindkey'^?'backward-delete-char
ifwhichsetterm>/dev/null;thensetterm-hbcolorbrightwhite
setterm-ulcolorcyan
fi
Usage
For usage, here are some basic tricks or features I've implemented:
uu: allows you to refresh your shell (when making modifications or adding new software)
utar: equivalent to tar -xzvf
..: equivalent to cd ..
...: equivalent to cd ../..
For the rest, I'll let you look at the file contents; I try to comment sufficiently.