Coloriser Terminal MacBook

Bonjour,

J'ai un MacBook Air avec un processeur M3, et je commence tout juste la programmation dessus. J'utilise, entre autres, le terminal pour faire du bash. Cependant, je n'ai aucune couleurs dans le terminal ; c'est donc un peu difficile de distinguer les lignes de commande d'un texte par exemple... 

Est-ce quelqu'un aurait une idée ? T__T

Merci par avance !

1 réponse

  1. Bonjour

    Il y a un plugin sous ZSH pour la coloration syntaxique du shell.

    Commencez par un

    brew install zsh

    Ouvrez ZSH (ce sera votre terminal par défaut maintenant) et poursuivez avec :

    brew install zsh-syntax-highlighting
    
    echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

    Redémarrez ZSH et vous avez un terminal coloré.


    1. Merci pour votre réponse !

      Malheureusement, j'ai une erreur après

      echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

      :(

    2. @ToucanVigilant33

      Arf. 

      Vu que zsh-syntax-highlighling est déjà installé, il n'y a peut-être pas besoin d'aller plus loin, essayez quelques commandes pour vous en assurer.

      Autrement, voici un lien : https://code2care.org/zsh/add-zsh-syntax-highlighting/

      Avant de modifier votre .zshrc, faites un 

      source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

      S'il n'y a pas d'erreur, vous pourrez immédiatement apprécier les fonctions du plug-in. Poursuivez pour rendre ça permanent.

      Sinon c'est qu'il est ailleurs.

    3. @luckydu43

      Pour être honnête, je ne suis pas sûre de comprendre grand-chose ^^'

      J'ai fait :

      source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

      Les couleurs s'affichent. Ensuite, j'ai de nouveau essayé de modifié le .zshrc avec 

      echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
      

      mais j'ai une erreur :(

      Et si je redémarre le terminal, je n'ai de nouveau plus les couleurs :(

    4. @ToucanVigilant33

      Le "echo" automatise l'action de saisie.

      Vous pouvez saisir à la main.

      Dans le terminal, tapez

      cd ~

      puis

      pwd

      Cela donne le chemin absolu du répertoire personnel.

      Allez-y avec l'explorateur de fichiers de MacOS et ouvrez le fichier .zshrc placé à la racine de ce dossier. (vim ~/.zshrc est plus direct mais n'est pas user-friendly)

      Une fois dans le fichier, tout en bas, insérez la ligne :

      source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

      Enregistrez puis redémarrez le terminal. Les couleurs seront là.

    5. @luckydu43

      Quand j'ouvre le fichier .zshrc, j'ai ça :

      Donc si je comprends bien, je copie :

      source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

      tout à la fin ?