Article original Publié le : 24 juillet 2021 Mise a jour le : – |
I. Installation des composants
- Installer le paquet zsh
1 |
$ sudo apt install zsh |
- Installer le projet oh-my-zsh
1 |
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
- Installation d’un nouveau thème
1 |
$ sudo apt install zsh-theme-powerlevel9k |
- Changement de la coloration
1 |
$ sudo apt install zsh-syntax-highlighting |
- Cloner ensuite le projet zsh-autosuggestions
1 |
$ git clone https://github.com/zsh-users/zsh-autosuggestions.git .zsh-autosuggestions |
II. Personnalisation de zsh
- Éditer le fichier .zshrc
1 |
$ vim ~/.zshrc |
- Dé-commenter la valeur pour vim
1 |
export EDITOR='vim' |
- Changement du thème
1 2 |
#ZSH_THEME="robbyrussell" ZSH_THEME="agnoster" |
- Changement du Plugin
1 2 |
#plugins=(git) plugins=(git colored-man-pages ansible cp sudo yum) |
- Ajouter de la valeur a l’historique
1 2 3 |
# Limite et taille export HISTSIZE=100000 export HISTFILESIZE=200000 |
1 2 |
# Affiche date et heure format international HIST_STAMPS="yyyy-mm-dd" |
1 2 |
# Supprimer doublon de la recherche (ctrl+r) setopt HIST_FIND_NO_DUPS |
1 2 |
# Supprimer commande qui pollue l'historique export HISTORY_IGNORE="(history|ls -ltr|ll|ls -la|lll|ls|pwd|exit|cd|cd ..)" |
- À la du fichier ajouter la valeur suivante
1 2 |
# Ajout clé ssh export SSH_KEY_PATH="~/.ssh/rsa_id" |
- Ajout de l’autosuggestion
1 2 |
# Autosuggestion source ~/.zsh-autosuggestions/zsh-autosuggestions.zsh |
III. Changer le shell par défaut
- Adapter le fichier .bashrc en ajoutant les valeurs en fin de fichier pour zsh (à adapter en fonction des chemins d’installation)
1 |
$ vim ~/.bashrc |
1 2 3 4 5 |
#sources source ~/.oh-my-zsh/oh-my-zsh.sh source /usr/share/powerlevel9k/powerlevel9k.zsh-theme source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh |
- Puis recharger le fichier
1 |
$ source .zshrc |
- Enfin changer le shell bash par zsh
1 |
$ chsh -s /bin/zsh |
IV. Tips
Quelques options possibles autour de l’historique
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
HISTFILE="$HOME/.zsh_history" HISTSIZE=10000000 SAVEHIST=10000000 setopt BANG_HIST # Treat the '!' character specially during expansion. setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. setopt SHARE_HISTORY # Share history between all sessions. setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. setopt HIST_FIND_NO_DUPS # Do not display a line previously found. setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. setopt HIST_VERIFY # Don't execute immediately upon history expansion. setopt HIST_BEEP # Beep when accessing nonexistent history. |
https://unix.stackexchange.com/questions/273861/unlimited-history-in-zsh
https://www.soberkoder.com/better-zsh-history/