Skip to content

Instantly share code, notes, and snippets.

@Linuus
Forked from agnoster/README.md
Created September 19, 2012 12:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Linuus/3749478 to your computer and use it in GitHub Desktop.
Save Linuus/3749478 to your computer and use it in GitHub Desktop.
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

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

Compatibility

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

TO MAKE THE FONTS WORK YOU NEED A POWERLINE PATCHED FONT: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts

What does it show?

  • Success (✔) or failure (✘) of previous command
  • Hostname
  • Git status
    • Branch (⭠) or detached head (➦)
    • Current branch / SHA1 in detached head state
    • Dirty working directory (±, color change)
  • Working directory
  • Elevated (root) privileges (⚡)

Screenshot

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.

Apparently the unicode characters don't display correctly on all systems. It would be nice to be able to say "this font will make it work, always". But what font?

# https://github.com/agnoster zsh theme
ZSH_THEME_GIT_PROMPT_DIRTY='±'
function _git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
echo "${ref/refs\/heads\//⭠ }$(parse_git_dirty)"
}
function _git_info() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
local BG_COLOR=green
if [[ -n $(parse_git_dirty) ]]; then
BG_COLOR=yellow
fi
echo "%{%K{$BG_COLOR}%}⮀%{%F{black}%} $(_git_prompt_info) %{%F{$BG_COLOR}%K{blue}%}⮀"
else
echo "%{%K{blue}%}⮀"
fi
}
PROMPT_HOST='%{%b%F{gray}%K{black}%} %(?.%{%F{green}%}✔.%{%F{red}%}✘)%{%F{gray}%} %m %{%F{black}%}'
PROMPT_DIR='%{%F{white}%} %1~ '
PROMPT_SU='%(!.%{%k%F{blue}%K{black}%}⮀%{%F{yellow}%} ⚡ %{%k%F{black}%}.%{%k%F{blue}%})⮀%{%f%k%b%}'
PROMPT='%{%f%b%k%}
$PROMPT_HOST$(_git_info)$PROMPT_DIR$PROMPT_SU '
@Linuus
Copy link
Author

Linuus commented Sep 19, 2012

For some reason I couldn't comment on the original gist...

The issue with the fonts is that you need a font that is patched for VimPowerline!
Menlo:
https://gist.github.com/1627888

A bunch of others:
https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts

@Linuus
Copy link
Author

Linuus commented Sep 19, 2012

Comments aren't wooorking!!!!

@Linuus
Copy link
Author

Linuus commented Sep 20, 2012

A comment. Does it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment