Skip to content

Instantly share code, notes, and snippets.

@grantnorwood
Created November 3, 2020 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grantnorwood/aae44d8a4f457cc03df1d0983124cafb to your computer and use it in GitHub Desktop.
Save grantnorwood/aae44d8a4f457cc03df1d0983124cafb to your computer and use it in GitHub Desktop.
Add a fancy prompt to zsh.
# Print the green/red arrow.
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
# Add the current directory & git prompt info
#
# This checks whether the path is longer then 5 elements, and in that case prints the first element (%-1~),
# some dots (/…/) and the last 3 elements. It is not exactly the same as paths that are not in your home
# directory, will also have the first element at the beginning, while bash just prints dots in that case:
#
# "%(5~|%-1~/…/%3~|%4~)"
#
# https://unix.stackexchange.com/questions/273529/shorten-path-in-zsh-prompt
#
PROMPT+='%{$fg[cyan]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} $(git_prompt_info)'
# BACKUP:
# PROMPT+=' %{$fg[cyan]%}%~%{$reset_color%} $(git_prompt_info)' # what does "%~%" do?
# PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' # keep this? what does "%c%" do?
# Configure git prompt
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment