4 comments on “zsh ANSI prompt

  1. thanks a lot for the tips on editing PS1 in zsh!

    Previously, I have used something called TerminalColours.bundle which allows further coloring of the terminal by having folders appear one color, executables another, etc in your Terminal environment. Now I use Visor which includes this bundle.

    Unfortunately, when i began using zsh instead of bash, the colors went away. In order to make colors work originally in bash, i had to add the lines

    #colorize the Terminal
    export GREP_OPTIONS='--color=auto'
    export CLICOLOR=1;

    to my .bash_profile in my home folder. I've tried making a .profile and .zsh_profile as equivalents but this didn't do the trick!

    do you have any ideas? your help is much appreciated, and i believe the solution is closely tied with this topic of changing colors which you have talked about ; )

    • I think these were the applications you mentioned:

      TerminalColors:
      http://www.culater.net/software/TerminalColors/TerminalColors.php

      Visor:
      https://visor.binaryage.com/

      I assume you're on a mac. If so, then things may be wildly different for you.

      I only see something vaguely similar with my environment variables..


      LS_OPTIONS='-F --color=auto'

      But your issue is at the shell level. This should probably work:


      echo -e "x1bx5b0;32;40mgreen text"

      If so, then it's an issue at the ls level. Maybe this works?:


      ls --color=always

      If that works then I'd suggest just solving this with an alias.

      If not, then I have no clue, sorry.

  2. For bright versions of the colors, try "fg_bold" instead of "fg": PS1="%{$fg_bold[red]%}%n%{$reset_color%}@%{$fg_bold[cyan]%}%m %{$fg_bold[yellow]%}%~ %{$reset_color%}%% "

    The secret sauce is in using "fg_bold" instead of "fg" for the color names.

    • Hey, thanks a lot! In my ~/.zshrc I did:


      autoload -U colors && colors
      PS1="%~ %{$fg_bold[blue]%}> %{$reset_color%}"

      One day I should bother with a more complex prompt.. I've been pretty minimal.

Leave a Reply

Your email address will not be published. Required fields are marked *