Skip to content

Instantly share code, notes, and snippets.

@ashebanow ashebanow/

forked from agnoster/
Last active Aug 29, 2015
What would you like to do?


A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark


NOTE: In all likelihood, you will need to install a Powerline-patched font for this theme to render correctly.

To test if your terminal and font support it, check that all the necessary characters are supported by copying the following command to your terminal: echo "⮀ ± ⭠ ➦ ✔ ✘ ⚡". The result should look like this:

Character Example

What does it show?

  • If the previous command failed (✘)
  • User @ Hostname (if user is not DEFAULT_USER, which can then be set in your profile)
  • Git status
    • Branch (⭠) or detached head (➦)
    • Current branch / SHA1 in detached head state
    • Dirty working directory (±, color change)
  • Working directory
  • Elevated (root) privileges ()


Future Work

I don't want to clutter it up too much, but I am toying with the idea of adding RVM (ruby version) and n (node.js version) display.

It's currently hideously slow, especially inside a git repo. I guess it's not overly so for comparable themes, but it bugs me, and I'd love to hear ideas about how to improve the performance.

Would be nice for the code to be a bit more sane and re-usable. Something to easily append a section with a given FG/BG, and add the correct opening and closing.

Also the dependency on a powerline-patched font is regrettable, but there's really no way to get that effect without it. Ideally there would be a way to check for compatibility, or maybe even fall back to one of the similar unicode glyphs.

# vim:ft=zsh ts=2 sw=2 sts=2
# agnoster's Theme -
# A Powerline-inspired theme for ZSH
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](
# In addition, I recommend the
# [Solarized theme]( and, if you're
# using it on Mac OS X, [iTerm 2]( over -
# it has significantly better color fidelity.
# # Goals
# The aim of this theme is to only show you *relevant* information. Like most
# prompts, it will only show git information when in a git working directory.
# However, it goes a step further: everything from the current user and
# hostname to whether the last call exited with an error to whether background
# jobs are running in this shell will all be displayed automatically when
# appropriate.
### Segment drawing
# A few utility functions to make it easy and re-usable to draw segmented prompts
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_segment() {
local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
echo -n "%{$bg%}%{$fg%} "
[[ -n $3 ]] && echo -n $3
# End the prompt, closing any open segments
prompt_end() {
if [[ -n $CURRENT_BG ]]; then
echo -n "%{%k%}"
echo -n "%{%f%}"
### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I)
prompt_context() {
local user=`whoami`
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
# Git: branch/detached head, dirty status
prompt_git() {
local ref dirty
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
prompt_segment green black
echo -n "${ref/refs\/heads\// }$dirty"
# Dir: current working directory
prompt_dir() {
prompt_segment blue black '%~'
# Status:
# - was there an error
# - am I root
# - are there background jobs?
prompt_status() {
local symbols
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
## Main prompt
build_prompt() {
PROMPT='%{%f%b%k%}$(build_prompt) '

This comment has been minimized.

Copy link

denniskig commented Jul 16, 2014

Thank you very much good sir. My glyphs weren't rendering at all well. Used yours and now it works a treat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.