1 # /etc/zshrc ou ~/.zshrc
3 # Ecrit par Alexis de Lattre (http://www.via.ecp.fr/~alexis/formation-linux/)
4 # Modifié par Olivier Tétard
10 # Gestion du ls : couleur + touche pas aux accents
11 alias ls='ls --classify --tabsize=0 --literal --color=auto --show-control-chars --human-readable'
13 alias cp='cp --interactive'
14 alias mv='mv --interactive'
15 alias rm='rm --interactive'
21 # Quelques alias pratiques
22 alias less='less --quiet'
24 alias df='df --human-readable'
25 alias du='du --human-readable'
26 alias grep='grep --color=auto'
27 alias aterm='aterm -sb -sl 2000 -bg black -fg white'
29 # alias ssh='LC_ALL=fr_FR luit ssh'
30 # alias sftp='LC_ALL=fr_FR luit sftp'
33 # 2. Prompt et Définition des touches
36 # Correspondance touches-fonction
37 bindkey '^A' beginning-of-line # Home
38 bindkey '^E' end-of-line # End
39 bindkey '^D' delete-char # Del
40 bindkey '
\e[3~' delete-char # Del
41 bindkey '
\e[2~' overwrite-mode # Insert
42 bindkey '
\e[5~' history-search-backward # PgUp
43 bindkey '
\e[6~' history-search-forward # PgDn
46 if [ "$TERM" = "linux" -o "$TERM" = "screen" -o "$TERM" = "rxvt" ]
48 bindkey '
\e[1~' beginning-of-line # Home
49 bindkey '
\e[4~' end-of-line # End
53 if [ "$TERM" = "xterm" ]
55 bindkey '
\e[H' beginning-of-line # Home
56 bindkey '
\e[F' end-of-line # End
59 # Gestion de la couleur pour 'ls' (exportation de LS_COLORS)
60 if [ -x /usr/bin/dircolors ]
62 if [ -r ~/.dir_colors ]
64 eval "`dircolors ~/.dir_colors`"
65 elif [ -r /etc/dir_colors ]
67 eval "`dircolors /etc/dir_colors`"
72 # 3. Options de zsh (cf 'man zshoptions')
75 # Je ne veux JAMAIS de beeps
80 # On veut utiliser les options de compétions avancées
83 # >| doit être utilisés pour pouvoir écraser un fichier déjà existant ;
86 # Ctrl+D est équivalent à 'logout'
89 # Affiche le code de sortie si différent de '0'
90 setopt print_exit_value
92 # Demande confirmation pour 'rm *'
93 unsetopt rm_star_silent
95 # Correction orthographique des commandes
98 # Schémas de complétion
101 # 1ère tabulation : complète jusqu'au bout de la partie commune
102 # 2ème tabulation : propose une liste de choix
103 # 3ème tabulation : complète avec le 1er item de la liste
104 # 4ème tabulation : complète avec le 2ème item de la liste, etc...
105 # -> c'est le schéma de complétion par défaut de zsh.
108 # 1ère tabulation : propose une liste de choix et complète avec le 1er item
110 # 2ème tabulation : complète avec le 2ème item de la liste, etc...
111 # Si vous voulez ce schéma, décommentez la ligne suivante :
112 #setopt menu_complete
115 # 1ère tabulation : complète jusqu'au bout de la partie commune et
116 # propose une liste de choix
117 # 2ème tabulation : complète avec le 1er item de la liste
118 # 3ème tabulation : complète avec le 2ème item de la liste, etc...
119 # Je n'ai malheureusement jamais réussi à mettre en place ce schéma
120 # alors qu'il me paraît être le schéma idéal !
121 # Si vous savez comment faire ça avec zsh -> alexis@via.ecp.fr
123 # Options de complétion
125 # Quand le dernier caractère d'une complétion est '/' et que l'on
126 # tape 'espace' après, le '/' est effaçé
127 setopt auto_remove_slash
129 # Fait la complétion sur les fichiers et répertoires cachés
132 # Traite les liens symboliques comme il faut
135 # Quand l'utilisateur commence sa commande par '!' pour faire de la
136 # complétion historique, il n'exécute pas la commande immédiatement
137 # mais il écrit la commande dans le prompt
140 # Si la commande est invalide mais correspond au nom d'un sous-répertoire
141 # exécuter 'cd sous-répertoire'
144 # L'exécution de "cd" met le répertoire d'où l'on vient sur la pile
147 # Ignore les doublons dans la pile
148 setopt pushd_ignore_dups
150 # N'affiche pas la pile après un "pushd" ou "popd"
153 # "pushd" sans argument = "pushd $HOME"
156 # Les jobs qui tournent en tâche de fond sont nicé à '0'
159 # N'envoie pas de "HUP" aux jobs qui tourent quand le shell se ferme
163 # 4. Paramètres de l'historique des commandes
166 # Nombre d'entrées dans l'historique
169 # Fichier où est stocké l'historique
170 export HISTFILE=$HOME/.history
173 # 5. Complétion des options des commandes
176 zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
177 zstyle ':completion:*' max-errors 3 numeric
178 zstyle ':completion:*' use-compctl false
188 (( TERMWIDTH = ${COLUMNS} - 1 ))
191 # Truncate the path if it's too long.
196 local promptsize=${#${(%):---(%n@%m:%l)---()--}}
197 local pwdsize=${#${(%):-%~}}
199 # if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
200 # ((PR_PWDLEN=$TERMWIDTH - $promptsize))
202 # PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
208 if [[ "$TERM" == "screen" ]]; then
209 local CMD=${1[(wr)^(*=*|sudo|-*)]}
210 echo -n "\ek$CMD\e\\"
217 # Need this so the prompt will work.
223 # See if we can use colors.
225 autoload colors zsh/terminfo
226 if [[ "$terminfo[colors]" -ge 8 ]]; then
229 for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
230 eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
231 eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
232 (( count = $count + 1 ))
234 PR_NO_COLOUR="%{$terminfo[sgr0]%}"
238 # See if we can use extended characters to look nicer.
241 set -A altchar ${(s..)terminfo[acsc]}
242 PR_SET_CHARSET="%{$terminfo[enacs]%}"
243 PR_SHIFT_IN="%{$terminfo[smacs]%}"
244 PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
249 # Decide if we need to set titlebar text.
253 PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
256 PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
265 # Decide whether to set a screen title
266 if [[ "$TERM" == "screen" ]]; then
267 PR_STITLE=$'%{\ekzsh\e\\%}'
273 # Finally, the prompt.
275 PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
276 $PR_BLUE$PR_HBAR$PR_SHIFT_OUT \
277 $PR_BLUE%(!.%SROOT%s.%n)$PR_BLUE@%m:%l:$PR_MAGENTA%$PR_PWDLEN<...<%~%<<$PR_BLUE $PR_SHIFT_IN$PR_HBAR
278 $PR_BLUE$PR_HBAR$PR_SHIFT_OUT \
279 %(?..$PR_LIGHT_RED%?$PR_BLUE:)\
281 $PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE$PR_NO_COLOUR '
283 # RPROMPT=' $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\
284 # ($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR'
286 PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
287 $PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
288 $PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
289 $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
293 alias krypton='ssh toutoune25@miskin.fr'