Configuration de zsh

zsh est un shell différent qui est très apprécié pour plusieurs fonctionnalités dont ils disposent telles que l'autocomplétion avancée, la proposition de correction de commandes, etc… Pour l'installer sur Debian la commande suivante suffira :

aptitude install zsh

La configuration suivante permet d'avoir un terminal coloré, un affichage de la date, et bien d'autres choses. Pour que la configuration soit prise en compte pour tous les utilisateurs, il faut modifier le fichier /etc/zsh/zshrc.

READNULLCMD=${PAGER:-/usr/bin/pager}

if [[ "$TERM" != emacs ]]; then
[[ -z "$terminfo[kdch1]" ]] || bindkey -M emacs "$terminfo[kdch1]" delete-char
[[ -z "$terminfo[khome]" ]] || bindkey -M emacs "$terminfo[khome]" beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M emacs "$terminfo[kend]" end-of-line
[[ -z "$terminfo[kich1]" ]] || bindkey -M emacs "$terminfo[kich1]" overwrite-mode
[[ -z "$terminfo[kdch1]" ]] || bindkey -M vicmd "$terminfo[kdch1]" vi-delete-char
[[ -z "$terminfo[khome]" ]] || bindkey -M vicmd "$terminfo[khome]" vi-beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M vicmd "$terminfo[kend]" vi-end-of-line
[[ -z "$terminfo[kich1]" ]] || bindkey -M vicmd "$terminfo[kich1]" overwrite-mode

[[ -z "$terminfo[cuu1]" ]] || bindkey -M viins "$terminfo[cuu1]" vi-up-line-or-history
[[ -z "$terminfo[cuf1]" ]] || bindkey -M viins "$terminfo[cuf1]" vi-forward-char
[[ -z "$terminfo[kcuu1]" ]] || bindkey -M viins "$terminfo[kcuu1]" vi-up-line-or-history
[[ -z "$terminfo[kcud1]" ]] || bindkey -M viins "$terminfo[kcud1]" vi-down-line-or-history
[[ -z "$terminfo[kcuf1]" ]] || bindkey -M viins "$terminfo[kcuf1]" vi-forward-char
[[ -z "$terminfo[kcub1]" ]] || bindkey -M viins "$terminfo[kcub1]" vi-backward-char

# ncurses fogyatekos
[[ "$terminfo[kcuu1]" == "O"* ]] && bindkey -M viins "${terminfo[kcuu1]/O/[}" vi-up-line-or-history
[[ "$terminfo[kcud1]" == "O"* ]] && bindkey -M viins "${terminfo[kcud1]/O/[}" vi-down-line-or-history
[[ "$terminfo[kcuf1]" == "O"* ]] && bindkey -M viins "${terminfo[kcuf1]/O/[}" vi-forward-char
[[ "$terminfo[kcub1]" == "O"* ]] && bindkey -M viins "${terminfo[kcub1]/O/[}" vi-backward-char
[[ "$terminfo[khome]" == "O"* ]] && bindkey -M viins "${terminfo[khome]/O/[}" beginning-of-line
[[ "$terminfo[kend]" == "O"* ]] && bindkey -M viins "${terminfo[kend]/O/[}" end-of-line
[[ "$terminfo[khome]" == "O"* ]] && bindkey -M emacs "${terminfo[khome]/O/[}" beginning-of-line
[[ "$terminfo[kend]" == "O"* ]] && bindkey -M emacs "${terminfo[kend]/O/[}" end-of-line
fi

zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
			     /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin

unalias run-help
autoload run-help

# If you don't want compinit called here, place the line
# skip_global_compinit=1
# in your $ZDOTDIR/.zshenv or $ZDOTDIR/.zprofice
if [[ -z "$skip_global_compinit" ]]; then
  autoload -U compinit
  compinit
fi

## Aliases
alias ls='ls --color=auto '
alias ll='ls -l'
alias la='ls -a'
alias lL='ls -la'
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias less='less --quiet'
alias myip4="w3m -4 -dump http://lv0.in/ip/ | head -n2"
alias myip6="w3m -6 -dump http://lv0.in/ip/ | head -n2"
alias aaa="aptitude update && aptitude full-upgrade && aptitude clean"

## Term Title display
if [ "$TERM" != "linux" ]; then precmd () {print -Pn "\e]0;%n@%m: %~\a"}; fi

## Keybindings and Prompt
# Lookup in /etc/termcap or /etc/terminfo else, you can get the right keycode
# by typing ^v and then type the key or key combination you want to use.
# "man zshzle" for the list of available actions
bindkey '^A'      beginning-of-line       # Home
bindkey '^E'      end-of-line             # End
bindkey '^D'      delete-char             # Del
bindkey '\e[3~'   delete-char             # Del
bindkey '\e[2~'   overwrite-mode          # Insert
bindkey '\e[5~'   history-search-backward # PgUp
bindkey '\e[6~'   history-search-forward  # PgDn
bindkey '\e[1;5C' forward-word            # C-Right
bindkey '\e[1;5D' backward-word           # C-Left

# Linux console, screen or rxvt.
if [ "$TERM" = "linux" -o "$TERM" = "screen" -o "$TERM" = "rxvt" -o "$TERM" = "screen-256color-bce" ]
then
  bindkey '\e[1~' beginning-of-line       # Home
  bindkey '\e[4~' end-of-line             # End
fi

# xterm
if [ "$TERM" = "xterm" ]
then
  bindkey '\e[H'  beginning-of-line       # Home
  bindkey '\e[F'  end-of-line             # End
  bindkey '\eOH'  beginning-of-line       # Home
  bindkey '\eOF'  end-of-line             # End
fi

# Colorized prompt. Root and normal users have different colors.
if [ "`id -u`" -eq 0 ]; then
  export PS1="%{%}%T%{%} %{%}%n%{%}@%{%}%m %{%}%~%{%}%#%{%} "
  export HISTFILE=/root/.history
else
  export PS1="%{%}%T%{%} %{%}%n%{%}@%{%}%m %{%}%~%{%}%#%{%} "
  export HISTFILE=$HOME/.history
fi

# Color Management for the `ls` command
if [ -x /usr/bin/dircolors ]
then
  if [ -r ~/.dir_colors ]
  then
    eval "`dircolors ~/.dir_colors`"
  elif [ -r /etc/dir_colors ]
  then
    eval "`dircolors /etc/dir_colors`"
  else
    eval "`dircolors`"
  fi
fi

## ZSH specific settings
# man zshoptions
setopt correct          # try to correct spelling of commands
setopt print_exit_value # print return value if non-zero
unsetopt beep           # no bell on error
unsetopt clobber        # must use >| to truncate existing files
unsetopt hist_beep      # no bell on error in history
unsetopt ignore_eof     # do not exist on end-of-file
unsetopt list_beep      # no bell on ambiguous completion
unsetopt rm_star_silent # ask for confirmation for `rm *' or `rm path/*'

# Completion style
unsetopt list_ambiguous # ??

# Completion options
# man zshoptions
setopt auto_cd            # if command is a path, cd into it
setopt auto_pushd         # make cd push old dir in dir stack
setopt auto_remove_slash  # self explicit
setopt chase_links        # resolve symlinks
setopt extended_glob      # activate complex pattern globbing
setopt glob_dots          # include dotfiles in globbing
setopt pushd_ignore_dups  # no duplicates in dir stack
setopt pushd_silent       # no dir stack after pushd or popd
setopt pushd_to_home      # `pushd` = `pushd $HOME`
unsetopt bg_nice          # no lower prio for background jobs
unsetopt hup              # no hup signal at shell exit

zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
zstyle ':completion:*' max-errors 3 numeric
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*' use-compctl false

HOSTS=(.trinaps.net .trinaps.com)
zstyle ':completion:*:hosts' hosts $HOSTS

autoload -U compinit
compinit

## History settings
export HISTORY=10000
export HISTSIZE=10000
export SAVEHIST=8000
setopt extended_history     # save timestamp and duration
setopt hist_ignore_all_dups # no duplicate
setopt hist_ignore_space    # ignore space prefixed commands
setopt hist_verify          # verify hist expansion
setopt inc_append_history   # append instead of replace
setopt share_history        # share hist between sessions

## Exports
export LANG="fr_FR.UTF-8"
export LANGUAGE="fr"
export LC_CTYPE="fr_FR.UTF-8"
export LC_NUMERIC="fr_FR.UTF-8"
export LC_TIME="fr_FR.UTF-8"
export LC_COLLATE="fr_FR.UTF-8"
export LC_MONETARY="fr_FR.UTF-8"
export LC_MESSAGES="fr_FR.UTF-8"
export LC_PAPER="fr_FR.UTF-8"
export LC_NAME="fr_FR.UTF-8"
export LC_ADDRESS="fr_FR.UTF-8"
export LC_TELEPHONE="fr_FR.UTF-8"
export LC_MEASUREMENT="fr_FR.UTF-8"
export LC_IDENTIFICATION="fr_FR.UTF-8"
export LC_ALL="fr_FR.UTF-8"
export EDITOR="/usr/bin/vim"
export PATH=/opt/bin:$PATH

Une fois la configuration faite, on peut changer de shell avec la commande chsh.

chsh
Mot de passe : 
Changement d'interpréteur de commandes initial pour respawner
Entrez la nouvelle valeur ou « Entrée » pour conserver la valeur proposée
	Interpréteur de commandes initial [/bin/zsh]: /bin/zsh

Au final, on a quelque chose de ce genre.