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'
27 alias egrep='egrep --color=tty -d skip'
28 alias egrpe='egrep --color=tty -d skip'
29 alias fgrep='fgrep --color=tty -d skip'
30 alias fgrpe='fgrep --color=tty -d skip'
31 alias grep='grep --color=tty -d skip'
32 alias grpe='grep --color=tty -d skip'
33 alias grep='grep --color=auto'
35 alias aterm='aterm -sb -sl 2000 -bg black -fg white'
37 # alias ssh='LC_ALL=fr_FR luit ssh'
38 # alias sftp='LC_ALL=fr_FR luit sftp'
41 # 2. Prompt et Définition des touches
44 # Correspondance touches-fonction
45 bindkey '^A' beginning-of-line # Home
46 bindkey '^E' end-of-line # End
47 bindkey '^D' delete-char # Del
48 bindkey '
\e[3~' delete-char # Del
49 bindkey '
\e[2~' overwrite-mode # Insert
50 bindkey '
\e[5~' history-search-backward # PgUp
51 bindkey '
\e[6~' history-search-forward # PgDn
54 if [ "$TERM" = "linux" -o "$TERM" = "screen" -o "$TERM" = "rxvt" ]
56 bindkey '
\e[1~' beginning-of-line # Home
57 bindkey '
\e[4~' end-of-line # End
61 if [ "$TERM" = "xterm" ]
63 bindkey '
\e[H' beginning-of-line # Home
64 bindkey '
\e[F' end-of-line # End
67 # Gestion de la couleur pour 'ls' (exportation de LS_COLORS)
68 if [ -x /usr/bin/dircolors ]
70 if [ -r ~/.dir_colors ]
72 eval "`dircolors ~/.dir_colors`"
73 elif [ -r /etc/dir_colors ]
75 eval "`dircolors /etc/dir_colors`"
80 # 3. Options de zsh (cf 'man zshoptions')
83 # Je ne veux JAMAIS de beeps
88 # On veut utiliser les options de compétions avancées
91 # >| doit être utilisés pour pouvoir écraser un fichier déjà existant ;
94 # Ctrl+D est équivalent à 'logout'
97 # Affiche le code de sortie si différent de '0'
98 setopt print_exit_value
100 # Demande confirmation pour 'rm *'
101 unsetopt rm_star_silent
103 # Correction orthographique des commandes
106 # Schémas de complétion
109 # 1ère tabulation : complète jusqu'au bout de la partie commune
110 # 2ème tabulation : propose une liste de choix
111 # 3ème tabulation : complète avec le 1er item de la liste
112 # 4ème tabulation : complète avec le 2ème item de la liste, etc...
113 # -> c'est le schéma de complétion par défaut de zsh.
116 # 1ère tabulation : propose une liste de choix et complète avec le 1er item
118 # 2ème tabulation : complète avec le 2ème item de la liste, etc...
119 # Si vous voulez ce schéma, décommentez la ligne suivante :
120 #setopt menu_complete
123 # 1ère tabulation : complète jusqu'au bout de la partie commune et
124 # propose une liste de choix
125 # 2ème tabulation : complète avec le 1er item de la liste
126 # 3ème tabulation : complète avec le 2ème item de la liste, etc...
127 # Je n'ai malheureusement jamais réussi à mettre en place ce schéma
128 # alors qu'il me paraît être le schéma idéal !
129 # Si vous savez comment faire ça avec zsh -> alexis@via.ecp.fr
131 # Options de complétion
133 # Quand le dernier caractère d'une complétion est '/' et que l'on
134 # tape 'espace' après, le '/' est effaçé
135 setopt auto_remove_slash
137 # Fait la complétion sur les fichiers et répertoires cachés
140 # Traite les liens symboliques comme il faut
143 # Quand l'utilisateur commence sa commande par '!' pour faire de la
144 # complétion historique, il n'exécute pas la commande immédiatement
145 # mais il écrit la commande dans le prompt
148 # Si la commande est invalide mais correspond au nom d'un sous-répertoire
149 # exécuter 'cd sous-répertoire'
152 # L'exécution de "cd" met le répertoire d'où l'on vient sur la pile
155 # Ignore les doublons dans la pile
156 setopt pushd_ignore_dups
158 # N'affiche pas la pile après un "pushd" ou "popd"
161 # "pushd" sans argument = "pushd $HOME"
164 # Les jobs qui tournent en tâche de fond sont nicé à '0'
167 # N'envoie pas de "HUP" aux jobs qui tourent quand le shell se ferme
171 # 4. Paramètres de l'historique des commandes
174 # Nombre d'entrées dans l'historique
177 # Fichier où est stocké l'historique
178 export HISTFILE=$HOME/.history
181 # 5. Complétion des options des commandes
184 zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
185 zstyle ':completion:*' max-errors 3 numeric
186 zstyle ':completion:*' use-compctl false
196 (( TERMWIDTH = ${COLUMNS} - 1 ))
199 # Truncate the path if it's too long.
204 local promptsize=${#${(%):---(%n@%m:%l)---()--}}
205 local pwdsize=${#${(%):-%~}}
207 # if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
208 # ((PR_PWDLEN=$TERMWIDTH - $promptsize))
210 # PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
216 if [[ "$TERM" == "screen" ]]; then
217 local CMD=${1[(wr)^(*=*|sudo|-*)]}
218 echo -n "\ek$CMD\e\\"
225 # Need this so the prompt will work.
231 # See if we can use colors.
233 autoload colors zsh/terminfo
234 if [[ "$terminfo[colors]" -ge 8 ]]; then
237 for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
238 eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
239 eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
240 (( count = $count + 1 ))
242 PR_NO_COLOUR="%{$terminfo[sgr0]%}"
246 # See if we can use extended characters to look nicer.
249 set -A altchar ${(s..)terminfo[acsc]}
250 PR_SET_CHARSET="%{$terminfo[enacs]%}"
251 PR_SHIFT_IN="%{$terminfo[smacs]%}"
252 PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
257 # Decide if we need to set titlebar text.
261 PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
264 PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
273 # Decide whether to set a screen title
274 if [[ "$TERM" == "screen" ]]; then
275 PR_STITLE=$'%{\ekzsh\e\\%}'
281 # Finally, the prompt.
283 PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
284 $PR_BLUE$PR_HBAR$PR_SHIFT_OUT \
285 $PR_BLUE%(!.%SROOT%s.%n)$PR_BLUE@%m:%l:$PR_MAGENTA%$PR_PWDLEN<...<%~%<<$PR_BLUE $PR_SHIFT_IN$PR_HBAR
286 $PR_BLUE$PR_HBAR$PR_SHIFT_OUT \
287 %(?..$PR_LIGHT_RED%?$PR_BLUE:)\
289 $PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE$PR_NO_COLOUR '
291 # RPROMPT=' $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\
292 # ($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR'
294 PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
295 $PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
296 $PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
297 $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
301 alias krypton='ssh toutoune25@miskin.fr'
303 if [ -x /usr/games/fortune ]; then
304 /usr/games/fortune /usr/share/games/fortunes/debian-hints