Manish Jethani

My zsh prompt

% echo $PROMPT 
%(?.✓.❗️%F{244}%?%f) %F{green}%(4~|%-1~/../%2~|%~)%f %#
% 

Let's break it down:

  1. Exit status

    This is the first part:

    %(?.✓.❗️%F{244}%?%f)
    

    ? checks for the exit status of the last command. If it indicates success, it shows a . If the last command failed, it shows a ❗️ followed by a space, followed by the error code in gray.

  2. Current working directory

    This is the second part:

    %F{green}%(4~|%-1~/../%2~|%~)%f
    

    Use the color green.

    If the path to the current working directory has 4 or more segments, show the first segment, followed by /../, followed by the last two segments. If not, show the entire path.

  3. Prompt symbol

    This is the third part:

    %#
    

    If the user is root, show #, otherwise show %.

This zsh prompt has served me well for over a year now.