# HG changeset patch # User Mikael Berthe # Date 1342360665 -7200 # Node ID e1da4a7a9e9290cfc43960a4242a8cbb0e73e4ac # Parent a906009be2b1b07a31f5643af6f68ca7a25bd2ce More modularization diff -r a906009be2b1 -r e1da4a7a9e92 zshrc --- a/zshrc Sun Jul 15 12:13:57 2012 +0200 +++ b/zshrc Sun Jul 15 15:57:45 2012 +0200 @@ -4,294 +4,54 @@ # options, key bindings, etc. # # Global Order: zshenv, zprofile, zshrc, zlogin - -# Copyright (c) 1995 Antoine VOUILLON -# Copyright (c) 1995-1999 Farzad FARID -# Copyright (c) Mikael BERTHE, 2001-2012 # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Mikael Berthe configuration file, 2001-2012 # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# La ligne suivante provoque parfois un message d'erreur non gênant -unalias run-help 2>/dev/null -autoload run-help - -autoload -U zmv - -# Protection des fichiers : rw-rw-r-- -# Protection des répertoires : rwxrwxr-x -if [[ $UID -eq 0 ]]; then - umask 022 -else - umask 002 -fi - -ulimit -c 0 -# Pas de limite pour les coredump -#ulimit -c unlimited -#unlimit coredumpsize - -######################## -# Definition du prompt # -######################## - -# Chargement des variables pour les couleurs -autoload colors; colors; +# Thanks to Antoine Vouillon, Farzad Farid, Seth House, +# Frank Terbeck and all others who have nice ideas! +# +# Local system-specific changes should be done in the +# zsh_local directory. -# Prompt complet (date, login, tty, hostname, cwd) sur une ligne -# (Invite de commande de secours...) -export PS1="%T %B[%n:%l]%b %S%m%s:%~%# " -# Prompt complet sur 2 lignes, N&B -#export PS1="%B%~%b -#%D{%m%d %H:%M} %B[%n:%l]%b %S%m%s%# " - -export PS2='%_.. > ' - -# Enable my Vim-like mode for supported terms -if [[ "$TERM" == "rxvt" || - "$TERM" == "rxvt-256color" || - "$TERM" == "rxvt-unicode" || - "$TERM" == "rxvt-unicode-256color" ]] -then - export SHOWMODE="on" -fi - -set shell=$SHELL -#cdpath=(~) - -if [[ -z "$FPATH" ]]; then - if [[ -d "/usr/lib/zsh/functions" ]]; then - FPATH="/usr/lib/zsh/functions" - elif [[ -d "/usr/share/zsh/functions" ]]; then - FPATH="/usr/share/zsh/functions" - else - echo "zsh: Could not set FPATH variable: no ../zsh/functions directory" - fi -fi - -# Pour configurer les couleurs créer le fichier /etc/LS_COLORS avec la -# commande "dircolors --print-database > /etc/LS_COLORS" et l'éditer. -# Taper 'man dircolors' pour plus de details -if [[ -x /usr/bin/dircolors ]]; then - if [[ -e /etc/LS_COLORS ]]; then - eval $(dircolors -b /etc/LS_COLORS) - else - eval $(dircolors -b) - fi - LS_OPTIONS=(--color=auto) - export LS_OPTIONS -fi +fpath=($ZDOTDIR/functions $fpath) #################### -# Options du shell # +# History settings # #################### -# Les noms des options sont écrits avec le souligné '_' optionnel pour -# faciliter la recherche dans la documentation de zsh. - -# Options de completion. Complète les noms de commandes/fichiers avec TAB -# listes toutes les possibilités, ne beep pas, boucle entre les choix par -# appui répété sur TAB. -#setopt menu_complete -setopt auto_list -setopt list_types -setopt no_list_beep -#setopt bash_auto_list - -# Correction automatique -setopt correct -unsetopt correct_all - -# Autres options - -# chdir « intelligent » -setopt auto_cd - -# On ne modifie pas des fichiers existants avec '>' et '>>' -setopt no_clobber - -unsetopt bg_nice -setopt no_flow_control -setopt no_hup -unsetopt sun_keyboard_hack - -# On n'écrase pas le fichier d'historique -setopt append_history -# On autorise les commentaires -setopt interactive_comments -# Les lignes commençant par une espace ne seront pas archivées -setopt hist_ignore_space -# fc -l ne sera pas archivé -setopt hist_no_store -# Pas de doublons dans l'historique -setopt hist_ignore_dups -# Les répertoires sont automatiquement mis dans la pile (cf. pushd, popd...) -setopt auto_pushd -# ... sans doublons -setopt pushd_ignore_dups -# Affiche la valeur de retour d'un programme (si non nulle) -setopt print_exit_value -# Essaie de réduire la liste des complétions -setopt list_packed - -#setopt nobeep - - -############################ -# Historique des commandes # -############################ - export SAVEHIST=4096 export HISTSIZE=4096 export HIST_EXPIRE_DUPS_FIRST export HISTFILE=$HOME/.history +##################### +# Terminal settings # +##################### -############################# -# Configuration des touches # -############################# - -# Pour que la touche Alt marche dans les xterm -bindkey -e +# Meta key and accents if [[ -z ${TERM:#xterm*} || -z ${TERM:#rxvt*} || -z ${TERM:#linux*} ]]; then stty pass8 - # L'option -m empêche l'utilisation des accents (è = ESC-h, etc.) - #bindkey -me -fi - -# Universelle -#bindkey '^Q' quoted-insert -bindkey '[2~' overwrite-mode # Ins -bindkey '[3~' delete-char # Suppr -bindkey '[5~' history-beginning-search-backward # PgUp -bindkey '[6~' history-beginning-search-forward # PgDn -bindkey '^[^I' reverse-menu-complete # ESC-Tab -bindkey '^Xc' copy-prev-word -bindkey '^Xf' _correct_filename -bindkey '^Xm' _most_recent_file - - -# Sur la console -if [[ "$TERM" == "console" || "$TERM" == "vt100" ]]; then - bindkey '^[[1~' beginning-of-line # Home - bindkey '^[[4~' end-of-line # End -fi - -# Dans un xterm term=linux -if [[ -z ${TERM:#linux*} || -z ${TERM:#screen} ]]; then - bindkey '^[[H' beginning-of-line # Home - bindkey '^[[F' end-of-line # End - bindkey '[1~' beginning-of-line # Home - bindkey '[4~' end-of-line # End -fi - -# Dans un xterm -if [[ -z ${TERM:#xterm*} ]]; then - bindkey '^[[H' beginning-of-line # Home - bindkey '^[[F' end-of-line # End - bindkey '[1~' beginning-of-line # Home - bindkey '[4~' end-of-line # End -fi - -# Dans un rxvt -if [[ -z ${TERM:#rxvt*} ]]; then - bindkey '^[[7~' beginning-of-line # Home - bindkey '^[[8~' end-of-line # End -fi - -# Sur un xterm, on differencie backspace et delete (?). -if [[ -z ${TERM:#xterm*} ]] -then - bindkey '^H' backward-delete-char # Backspace - bindkey '^?' backward-delete-char # Backspace fi -# En combinaison avec le "keycode 22 = Backspace" du .Xmodmap pour -# faire marcher le backspace dans Netscape +# Can be necessary fo some environments stty erase '^?' -####################################################### -# Completion, lire le man pour plus de renseignements # -####################################################### - -#compctl -g '*(-/)' cd pushd -compctl -g '.*(-/) *(-/)' cd pushd -compctl -g '.*(-/) *(-/)' rmdir -compctl -g '*.Z *.z *.gz *.tgz *(-/)' zcat gunzip -compctl -g '*.Z *.z *.gz *.tgz *.tar *.bz2 *(-/)' tart tarx tar -compctl -g '*.bz2 *(-/)' bz2cat bunzip2 -compctl -g '*.zip *.ZIP *.exe *.EXE *(-/)' unzip -compctl -g '*.ps *.ps.gz *(-/)' gs ghostview gv evince -compctl -g '*.tex* *.latex* *(-/)' tex latex texi2dvi -compctl -g '*.dvi *(-/)' xdvi dvips -compctl -j -P % -x 's[-] p[1]' -k signals -- kill -compctl -l '' nohup exec -compctl -u -x 's[@]' -k hosts -- finger -compctl -m info -compctl -m -g '*.1 *(-/)' man -compctl -c which where type -compctl -g '*.pdf *(-/)' evince - -# Hosts completion - -if [ -f ~/.ssh/config ]; then - hosts=($hosts `grep ^Host ~/.ssh/config | sed s/Host\ // | egrep -v '^\*$'`) -fi -if [ "$hosts" ]; then - zstyle ':completion:*:hosts' hosts $hosts -fi +################## +# Default prompt # +################## -########## -# zstyle # -########## - -zstyle ':completion:*' completer _expand _complete _correct _approximate -zstyle ':completion:*' completions 1 -zstyle ':completion:*' format 'Completing %B%d%b%:' -zstyle ':completion:*' glob 1 -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} -zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s -zstyle ':completion:*' max-errors 2 numeric -zstyle ':completion:*' menu select=3 -zstyle ':completion:*' prompt '%e erreur(s)...' -zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' -zstyle ':completion:*' substitute 1 - -autoload -Uz compinit -compinit - -# Needed for menuselect below -zmodload zsh/complist - -autoload -U incremental-complete-word -zle -N incremental-complete-word -bindkey 'i' incremental-complete-word - -bindkey -M menuselect '' accept-and-infer-next-history - -bindkey -s '' '/' -bindkey -s '' ',' - +# Full prompt (date, login, tty, hostname, cwd) on one +# line. (This is the fallback prompt...) +export PS1="%T %B[%n:%l]%b %S%m%s:%~%# " +export PS2='%_.. > ' ############################## # Source configuration files # ############################## -fpath=($ZDOTDIR/functions $fpath) - +# Common configuration files for rc in $ZDOTDIR/zshrc.d/??-*.zrc; do [[ -r ${rc} ]] && source "$rc" done diff -r a906009be2b1 -r e1da4a7a9e92 zshrc.d/05-autoload.zrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zshrc.d/05-autoload.zrc Sun Jul 15 15:57:45 2012 +0200 @@ -0,0 +1,9 @@ + +# In case run-help is not defined +unalias run-help &> /dev/null +autoload run-help + +autoload -U zmv + +# Load standard ANSI color codes in shell parameters +autoload -U colors && colors diff -r a906009be2b1 -r e1da4a7a9e92 zshrc.d/10-default-bindings.zrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zshrc.d/10-default-bindings.zrc Sun Jul 15 15:57:45 2012 +0200 @@ -0,0 +1,52 @@ + +# Emacs mode bindings + +bindkey -e + +#bindkey '^Q' quoted-insert +bindkey '[2~' overwrite-mode # Ins +bindkey '[3~' delete-char # Suppr +bindkey '[5~' history-beginning-search-backward # PgUp +bindkey '[6~' history-beginning-search-forward # PgDn +bindkey '^[^I' reverse-menu-complete # ESC-Tab +bindkey '^Xc' copy-prev-word +bindkey '^Xf' _correct_filename +bindkey '^Xm' _most_recent_file + +bindkey -s '' '/' +bindkey -s '' ',' + +# Sur la console +if [[ "$TERM" == "console" || "$TERM" == "vt100" ]]; then + bindkey '^[[1~' beginning-of-line # Home + bindkey '^[[4~' end-of-line # End +fi + +# Dans un xterm term=linux +if [[ -z ${TERM:#linux*} || -z ${TERM:#screen} ]]; then + bindkey '^[[H' beginning-of-line # Home + bindkey '^[[F' end-of-line # End + bindkey '[1~' beginning-of-line # Home + bindkey '[4~' end-of-line # End +fi + +# Dans un xterm +if [[ -z ${TERM:#xterm*} ]]; then + bindkey '^[[H' beginning-of-line # Home + bindkey '^[[F' end-of-line # End + bindkey '[1~' beginning-of-line # Home + bindkey '[4~' end-of-line # End +fi + +# Dans un rxvt +if [[ -z ${TERM:#rxvt*} ]]; then + bindkey '^[[7~' beginning-of-line # Home + bindkey '^[[8~' end-of-line # End +fi + +# Sur un xterm, on differencie backspace et delete (?). +if [[ -z ${TERM:#xterm*} ]] +then + bindkey '^H' backward-delete-char # Backspace + bindkey '^?' backward-delete-char # Backspace +fi diff -r a906009be2b1 -r e1da4a7a9e92 zshrc.d/10-shell-options.zrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zshrc.d/10-shell-options.zrc Sun Jul 15 15:57:45 2012 +0200 @@ -0,0 +1,72 @@ + +################# +# Shell options # +################# +# +# Most of these settings come from my original setup from +# Antoine Vouillon and Farzad Farid. +# Comments are still in French. + +# Les noms des options sont écrits avec le souligné '_' optionnel pour +# faciliter la recherche dans la documentation de zsh. + +# Options de completion. Complète les noms de commandes/fichiers avec TAB +# listes toutes les possibilités, ne beep pas, boucle entre les choix par +# appui répété sur TAB. +#setopt menu_complete +setopt auto_list +setopt list_types +setopt no_list_beep +#setopt bash_auto_list + +# Correction automatique +setopt correct +unsetopt correct_all + +# Autres options + +# chdir « intelligent » +setopt auto_cd + +# On ne modifie pas des fichiers existants avec '>' et '>>' +setopt no_clobber + +unsetopt bg_nice +setopt no_flow_control +setopt no_hup +unsetopt sun_keyboard_hack + +# On n'écrase pas le fichier d'historique +setopt append_history +# On autorise les commentaires +setopt interactive_comments +# Les lignes commençant par une espace ne seront pas archivées +setopt hist_ignore_space +# fc -l ne sera pas archivé +setopt hist_no_store +# Pas de doublons dans l'historique +setopt hist_ignore_dups +# Les répertoires sont automatiquement mis dans la pile (cf. pushd, popd...) +setopt auto_pushd +# ... sans doublons +setopt pushd_ignore_dups +# Affiche la valeur de retour d'un programme (si non nulle) +setopt print_exit_value +# Essaie de réduire la liste des complétions +setopt list_packed + +#setopt nobeep + + +# Other shell configuration items # +################################### + +# No core dumps +ulimit -c 0 + +# File/directory masks +if [[ $UID -eq 0 ]]; then + umask 022 +else + umask 002 +fi diff -r a906009be2b1 -r e1da4a7a9e92 zshrc.d/15-colors.zrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zshrc.d/15-colors.zrc Sun Jul 15 15:57:45 2012 +0200 @@ -0,0 +1,16 @@ + +# You can customize ls colors by generating the file /etc/LS_COLORS +# (using "dircolors --print-database > /etc/LS_COLORS") and +# updating it. +# Check 'man dircolors' for more information. +# Thanks to Antoine Vouillon and Farzad Farid. + +if [[ -x /usr/bin/dircolors ]]; then + if [[ -e /etc/LS_COLORS ]]; then + eval $(dircolors -b /etc/LS_COLORS) + else + eval $(dircolors -b) + fi + LS_OPTIONS=(--color=auto) + export LS_OPTIONS +fi diff -r a906009be2b1 -r e1da4a7a9e92 zshrc.d/15-completion.zrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zshrc.d/15-completion.zrc Sun Jul 15 15:57:45 2012 +0200 @@ -0,0 +1,51 @@ + +compctl -g '.*(-/) *(-/)' cd pushd +compctl -g '.*(-/) *(-/)' rmdir +compctl -g '*.Z *.z *.gz *.tgz *(-/)' zcat gunzip +compctl -g '*.Z *.z *.gz *.tgz *.tar *.bz2 *(-/)' tart tarx tar +compctl -g '*.bz2 *(-/)' bz2cat bunzip2 +compctl -g '*.zip *.ZIP *.exe *.EXE *(-/)' unzip +compctl -g '*.ps *.ps.gz *(-/)' gs ghostview gv evince +compctl -g '*.tex* *.latex* *(-/)' tex latex texi2dvi +compctl -g '*.dvi *(-/)' xdvi dvips +compctl -j -P % -x 's[-] p[1]' -k signals -- kill +compctl -l '' nohup exec +compctl -u -x 's[@]' -k hosts -- finger +compctl -m info +compctl -m -g '*.1 *(-/)' man +compctl -c which where type +compctl -g '*.pdf *(-/)' evince + +# Hosts completion + +if [ -f ~/.ssh/config ]; then + hosts=($hosts `grep ^Host ~/.ssh/config | sed s/Host\ // | egrep -v '^\*$'`) +fi +if [ "$hosts" ]; then + zstyle ':completion:*:hosts' hosts $hosts +fi + + +zstyle ':completion:*' completer _expand _complete _correct _approximate +zstyle ':completion:*' completions 1 +zstyle ':completion:*' format 'Completing %B%d%b%:' +zstyle ':completion:*' glob 1 +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s +zstyle ':completion:*' max-errors 2 numeric +zstyle ':completion:*' menu select=3 +zstyle ':completion:*' prompt '%e erreur(s)...' +zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' +zstyle ':completion:*' substitute 1 + +autoload -Uz compinit +compinit + +# Needed for menuselect below +zmodload zsh/complist + +autoload -U incremental-complete-word +zle -N incremental-complete-word +bindkey 'i' incremental-complete-word + +bindkey -M menuselect '' accept-and-infer-next-history diff -r a906009be2b1 -r e1da4a7a9e92 zshrc.d/20-prompt.zrc --- a/zshrc.d/20-prompt.zrc Sun Jul 15 12:13:57 2012 +0200 +++ b/zshrc.d/20-prompt.zrc Sun Jul 15 15:57:45 2012 +0200 @@ -6,6 +6,16 @@ export HG_ROOT_CMD +# Enable my Vim-like mode for supported terms +if [[ "$TERM" == "rxvt" || + "$TERM" == "rxvt-256color" || + "$TERM" == "rxvt-unicode" || + "$TERM" == "rxvt-unicode-256color" ]] +then + export SHOWMODE="on" +fi + + ### Extended prompts function __prompt_path_color {