zshrc
changeset 13 e1da4a7a9e92
parent 8 3f68f355bf1a
child 38 54b86a545f6c
child 40 6eeab84c3f15
equal deleted inserted replaced
12:a906009be2b1 13:e1da4a7a9e92
     2 # This file is sourced only for interactive shells. It
     2 # This file is sourced only for interactive shells. It
     3 # should contain commands to set up aliases, functions,
     3 # should contain commands to set up aliases, functions,
     4 # options, key bindings, etc.
     4 # options, key bindings, etc.
     5 #
     5 #
     6 # Global Order: zshenv, zprofile, zshrc, zlogin
     6 # Global Order: zshenv, zprofile, zshrc, zlogin
       
     7 #
       
     8 # Mikael Berthe configuration file, 2001-2012
       
     9 #
       
    10 # Thanks to Antoine Vouillon, Farzad Farid, Seth House,
       
    11 # Frank Terbeck and all others who have nice ideas!
       
    12 #
       
    13 # Local system-specific changes should be done in the
       
    14 # zsh_local directory.
     7 
    15 
     8 # Copyright (c) 1995 Antoine VOUILLON
       
     9 # Copyright (c) 1995-1999 Farzad FARID
       
    10 # Copyright (c) Mikael BERTHE, 2001-2012
       
    11 #
       
    12 #   This program is free software; you can redistribute it and/or modify
       
    13 #   it under the terms of the GNU General Public License as published by
       
    14 #   the Free Software Foundation; either version 2 of the License, or
       
    15 #   (at your option) any later version.
       
    16 #
       
    17 #   This program is distributed in the hope that it will be useful,
       
    18 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    19 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    20 #   GNU General Public License for more details.
       
    21 #
       
    22 #   You should have received a copy of the GNU General Public License
       
    23 #   along with this program; if not, write to the Free Software
       
    24 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    25 
    16 
    26 # La ligne suivante provoque parfois un message d'erreur non gênant
    17 fpath=($ZDOTDIR/functions $fpath)
    27 unalias run-help 2>/dev/null
       
    28 autoload run-help
       
    29 
       
    30 autoload -U zmv
       
    31 
       
    32 # Protection des fichiers    : rw-rw-r--
       
    33 # Protection des répertoires : rwxrwxr-x
       
    34 if [[ $UID -eq 0 ]]; then
       
    35   umask 022
       
    36 else
       
    37   umask 002
       
    38 fi
       
    39 
       
    40 ulimit -c 0
       
    41 # Pas de limite pour les coredump
       
    42 #ulimit -c unlimited
       
    43 #unlimit coredumpsize
       
    44 
       
    45 ########################
       
    46 # Definition du prompt #
       
    47 ########################
       
    48 
       
    49 # Chargement des variables pour les couleurs
       
    50 autoload colors; colors;
       
    51 
       
    52 # Prompt complet (date, login, tty, hostname, cwd) sur une ligne
       
    53 # (Invite de commande de secours...)
       
    54 export PS1="%T %B[%n:%l]%b %S%m%s:%~%# "
       
    55 
       
    56 # Prompt complet sur 2 lignes, N&B
       
    57 #export PS1="%B%~%b
       
    58 #%D{%m%d %H:%M} %B[%n:%l]%b %S%m%s%# "
       
    59 
       
    60 export PS2='%_.. > '
       
    61 
       
    62 # Enable my Vim-like mode for supported terms
       
    63 if [[ "$TERM" == "rxvt" ||
       
    64       "$TERM" == "rxvt-256color" ||
       
    65       "$TERM" == "rxvt-unicode" ||
       
    66       "$TERM" == "rxvt-unicode-256color" ]]
       
    67 then
       
    68     export SHOWMODE="on"
       
    69 fi
       
    70 
       
    71 set shell=$SHELL
       
    72 #cdpath=(~)
       
    73 
       
    74 if [[ -z "$FPATH" ]]; then
       
    75   if [[ -d "/usr/lib/zsh/functions" ]]; then
       
    76     FPATH="/usr/lib/zsh/functions"
       
    77   elif [[ -d "/usr/share/zsh/functions" ]]; then
       
    78     FPATH="/usr/share/zsh/functions"
       
    79   else
       
    80     echo "zsh: Could not set FPATH variable: no ../zsh/functions directory"
       
    81   fi
       
    82 fi
       
    83 
       
    84 # Pour configurer les couleurs créer le fichier /etc/LS_COLORS avec la
       
    85 # commande "dircolors --print-database > /etc/LS_COLORS" et l'éditer.
       
    86 # Taper 'man dircolors' pour plus de details
       
    87 if [[ -x /usr/bin/dircolors ]]; then
       
    88   if [[ -e /etc/LS_COLORS ]]; then
       
    89     eval $(dircolors -b /etc/LS_COLORS)
       
    90   else
       
    91     eval $(dircolors -b)
       
    92   fi
       
    93   LS_OPTIONS=(--color=auto)
       
    94   export LS_OPTIONS
       
    95 fi
       
    96 
    18 
    97 
    19 
    98 ####################
    20 ####################
    99 # Options du shell #
    21 # History settings #
   100 ####################
    22 ####################
   101 
       
   102 # Les noms des options sont écrits avec le souligné '_' optionnel pour
       
   103 # faciliter la recherche dans la documentation de zsh.
       
   104 
       
   105 # Options de completion. Complète les noms de commandes/fichiers avec TAB
       
   106 # listes toutes les possibilités, ne beep pas, boucle entre les choix par
       
   107 # appui répété sur TAB.
       
   108 #setopt menu_complete
       
   109 setopt auto_list
       
   110 setopt list_types
       
   111 setopt no_list_beep
       
   112 #setopt bash_auto_list
       
   113 
       
   114 # Correction automatique
       
   115 setopt correct
       
   116 unsetopt correct_all
       
   117 
       
   118 # Autres options
       
   119 
       
   120 # chdir « intelligent »
       
   121 setopt auto_cd
       
   122 
       
   123 # On ne modifie pas des fichiers existants avec '>' et '>>'
       
   124 setopt no_clobber
       
   125 
       
   126 unsetopt bg_nice
       
   127 setopt no_flow_control
       
   128 setopt no_hup
       
   129 unsetopt sun_keyboard_hack
       
   130 
       
   131 # On n'écrase pas le fichier d'historique
       
   132 setopt append_history
       
   133 # On autorise les commentaires
       
   134 setopt interactive_comments
       
   135 # Les lignes commençant par une espace ne seront pas archivées
       
   136 setopt hist_ignore_space
       
   137 # fc -l ne sera pas archivé
       
   138 setopt hist_no_store
       
   139 # Pas de doublons dans  l'historique
       
   140 setopt hist_ignore_dups
       
   141 # Les répertoires sont automatiquement mis dans la pile (cf. pushd, popd...)
       
   142 setopt auto_pushd
       
   143 # ... sans doublons
       
   144 setopt pushd_ignore_dups
       
   145 # Affiche la valeur de retour d'un programme (si non nulle)
       
   146 setopt print_exit_value
       
   147 # Essaie de réduire la liste des complétions
       
   148 setopt list_packed
       
   149 
       
   150 #setopt nobeep
       
   151 
       
   152 
       
   153 ############################
       
   154 # Historique des commandes #
       
   155 ############################
       
   156 
    23 
   157 export SAVEHIST=4096
    24 export SAVEHIST=4096
   158 export HISTSIZE=4096
    25 export HISTSIZE=4096
   159 export HIST_EXPIRE_DUPS_FIRST
    26 export HIST_EXPIRE_DUPS_FIRST
   160 export HISTFILE=$HOME/.history
    27 export HISTFILE=$HOME/.history
   161 
    28 
       
    29 #####################
       
    30 # Terminal settings #
       
    31 #####################
   162 
    32 
   163 #############################
    33 # Meta key and accents
   164 # Configuration des touches #
       
   165 #############################
       
   166 
       
   167 # Pour que la touche Alt marche dans les xterm
       
   168 bindkey -e
       
   169 if [[ -z ${TERM:#xterm*} || -z ${TERM:#rxvt*} || -z ${TERM:#linux*} ]]; then
    34 if [[ -z ${TERM:#xterm*} || -z ${TERM:#rxvt*} || -z ${TERM:#linux*} ]]; then
   170   stty pass8
    35   stty pass8
   171   # L'option -m empêche l'utilisation des accents (è = ESC-h, etc.)
       
   172   #bindkey -me
       
   173 fi
    36 fi
   174 
    37 
   175 # Universelle
    38 # Can be necessary fo some environments
   176 #bindkey '^Q'    quoted-insert
       
   177 bindkey '[2~' overwrite-mode                    # Ins
       
   178 bindkey '[3~' delete-char                       # Suppr
       
   179 bindkey '[5~' history-beginning-search-backward # PgUp
       
   180 bindkey '[6~' history-beginning-search-forward  # PgDn
       
   181 bindkey '^[^I'  reverse-menu-complete             # ESC-Tab
       
   182 bindkey '^Xc'   copy-prev-word
       
   183 bindkey '^Xf'   _correct_filename
       
   184 bindkey '^Xm'   _most_recent_file
       
   185 
       
   186 
       
   187 # Sur la console
       
   188 if [[ "$TERM" == "console" || "$TERM" == "vt100" ]]; then
       
   189   bindkey '^[[1~' beginning-of-line       # Home
       
   190   bindkey '^[[4~' end-of-line             # End
       
   191 fi
       
   192 
       
   193 # Dans un xterm term=linux
       
   194 if [[ -z ${TERM:#linux*} || -z ${TERM:#screen} ]]; then
       
   195   bindkey '^[[H'  beginning-of-line       # Home
       
   196   bindkey '^[[F'  end-of-line             # End
       
   197   bindkey '[1~'  beginning-of-line       # Home
       
   198   bindkey '[4~'  end-of-line             # End
       
   199 fi
       
   200 
       
   201 # Dans un xterm
       
   202 if [[ -z ${TERM:#xterm*} ]]; then
       
   203   bindkey '^[[H'  beginning-of-line       # Home
       
   204   bindkey '^[[F'  end-of-line             # End
       
   205   bindkey '[1~'  beginning-of-line       # Home
       
   206   bindkey '[4~'  end-of-line             # End
       
   207 fi
       
   208 
       
   209 # Dans un rxvt
       
   210 if [[ -z ${TERM:#rxvt*} ]]; then
       
   211   bindkey '^[[7~' beginning-of-line       # Home
       
   212   bindkey '^[[8~' end-of-line             # End
       
   213 fi
       
   214 
       
   215 # Sur un xterm, on differencie backspace et delete (?).
       
   216 if [[ -z ${TERM:#xterm*} ]]
       
   217 then
       
   218   bindkey '^H'  backward-delete-char    # Backspace
       
   219   bindkey '^?'  backward-delete-char    # Backspace
       
   220 fi
       
   221 
       
   222 # En combinaison avec le "keycode 22 = Backspace" du .Xmodmap pour
       
   223 # faire marcher le backspace dans Netscape
       
   224 stty erase '^?'
    39 stty erase '^?'
   225 
    40 
   226 #######################################################
    41 ##################
   227 # Completion, lire le man pour plus de renseignements #
    42 # Default prompt #
   228 #######################################################
    43 ##################
   229 
    44 
   230 #compctl -g '*(-/)' cd pushd
    45 # Full prompt (date, login, tty, hostname, cwd) on one
   231 compctl -g '.*(-/) *(-/)' cd pushd
    46 # line.  (This is the fallback prompt...)
   232 compctl -g '.*(-/) *(-/)' rmdir
    47 export PS1="%T %B[%n:%l]%b %S%m%s:%~%# "
   233 compctl -g '*.Z *.z *.gz *.tgz *(-/)' zcat gunzip
    48 export PS2='%_.. > '
   234 compctl -g '*.Z *.z *.gz *.tgz *.tar *.bz2 *(-/)' tart tarx tar
       
   235 compctl -g '*.bz2 *(-/)' bz2cat bunzip2
       
   236 compctl -g '*.zip *.ZIP *.exe *.EXE *(-/)' unzip
       
   237 compctl -g '*.ps *.ps.gz *(-/)' gs ghostview gv evince
       
   238 compctl -g '*.tex* *.latex* *(-/)' tex latex texi2dvi
       
   239 compctl -g '*.dvi *(-/)' xdvi dvips
       
   240 compctl -j -P % -x 's[-] p[1]' -k signals -- kill
       
   241 compctl -l '' nohup exec
       
   242 compctl -u -x 's[@]' -k hosts -- finger
       
   243 compctl -m info
       
   244 compctl -m -g '*.1 *(-/)' man
       
   245 compctl -c which where type
       
   246 compctl -g '*.pdf *(-/)' evince
       
   247 
       
   248 # Hosts completion
       
   249 
       
   250 if [ -f ~/.ssh/config ]; then
       
   251   hosts=($hosts `grep ^Host ~/.ssh/config | sed s/Host\ // | egrep -v '^\*$'`)
       
   252 fi
       
   253 if [ "$hosts" ]; then
       
   254   zstyle ':completion:*:hosts' hosts $hosts
       
   255 fi
       
   256 
       
   257 ##########
       
   258 # zstyle #
       
   259 ##########
       
   260 
       
   261 zstyle ':completion:*' completer _expand _complete _correct _approximate
       
   262 zstyle ':completion:*' completions 1
       
   263 zstyle ':completion:*' format 'Completing %B%d%b%:'
       
   264 zstyle ':completion:*' glob 1
       
   265 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
       
   266 zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
       
   267 zstyle ':completion:*' max-errors 2 numeric
       
   268 zstyle ':completion:*' menu select=3
       
   269 zstyle ':completion:*' prompt '%e erreur(s)...'
       
   270 zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
       
   271 zstyle ':completion:*' substitute 1
       
   272 
       
   273 autoload -Uz compinit
       
   274 compinit
       
   275 
       
   276 # Needed for menuselect below
       
   277 zmodload zsh/complist
       
   278 
       
   279 autoload -U incremental-complete-word
       
   280 zle -N incremental-complete-word
       
   281 bindkey 'i' incremental-complete-word
       
   282 
       
   283 bindkey -M menuselect '' accept-and-infer-next-history
       
   284 
       
   285 bindkey -s '' '/'
       
   286 bindkey -s '' ','
       
   287 
       
   288 
    49 
   289 ##############################
    50 ##############################
   290 # Source configuration files #
    51 # Source configuration files #
   291 ##############################
    52 ##############################
   292 
    53 
   293 fpath=($ZDOTDIR/functions $fpath)
    54 # Common configuration files
   294 
       
   295 for rc in $ZDOTDIR/zshrc.d/??-*.zrc; do
    55 for rc in $ZDOTDIR/zshrc.d/??-*.zrc; do
   296     [[ -r ${rc} ]] && source "$rc"
    56     [[ -r ${rc} ]] && source "$rc"
   297 done
    57 done
   298 unset rc
    58 unset rc
   299 
    59