Skip to content

Instantly share code, notes, and snippets.

@smileart smileart/README.md forked from agnoster/README.md
Last active May 10, 2019

Embed
What would you like to do?
My ZSH Theme — Agnoster Mod

My modified fork of 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

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?

# Original theme 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
FG_COLOR=black
fi
if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
BG_COLOR=red
FG_COLOR=white
fi
echo "%{%K{$BG_COLOR}%}⮀%{%F{$FG_COLOR}%} $(_git_prompt_info) %{%F{$BG_COLOR}%K{blue}%}⮀"
else
echo "%{%K{blue}%}⮀"
fi
}
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
PROMPT_HOST='%{%b%F{gray}%K{black}%} %(?.%{%F{green}%}✔.%{%F{red}%}✘)%{%F{yellow}%} %n %{%F{black}%}'
PROMPT_DIR='%{%F{white}%} %~% '
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
$(virtualenv_info)❯ '
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
@acook

This comment has been minimized.

Copy link

commented Aug 31, 2013

What is prompt_smileart_setup?

@ptran123

This comment has been minimized.

Copy link

commented Nov 9, 2013

Concurred with acook. I get this show in the terminal: command not found: prompt_smileart_setup.

@hql287

This comment has been minimized.

Copy link

commented Nov 14, 2013

Have no idea what it is but just comment the last line out and everything should be working properly!

@kpvarma27

This comment has been minimized.

Copy link

commented Nov 23, 2013

I was able to install zsh , solarized colors with agonster.theme.
however its not showing the fonts properly.
not sure how to install powerline fonts properly in mac.

@skrauchenia

This comment has been minimized.

Copy link

commented Dec 4, 2013

Check the following:
terminal settings -> Advanced -> Escape non-ASCII input with Control-V
That checkbox should be unchecked

Hope this helps

@skrauchenia

This comment has been minimized.

Copy link

commented Dec 4, 2013

How can I customise arrow with current path? How to change either it's background or font colour?

@smileart

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2014

OH SHI~ I'm so sorry guys! Gist doesn't have comments notification, so I missed all your questions! If you would have any more questions, suggestions, bug reports, write right to my email! Thanks and sorry once again.

@srhmgn

This comment has been minimized.

Copy link

commented Apr 2, 2014

Box unchecked in my Terminal app (though using iTerm2) and still can't see all the characters when I install the theme. Can't even see them in Chrome. Any tips?

@achmiral

This comment has been minimized.

Copy link

commented May 21, 2015

Can i use this theme on gnome-terminal ubuntu?

@scottbaron

This comment has been minimized.

Copy link

commented Jun 13, 2015

Can someone tell me how to get the clock to appear in the older version of agnoster? Or point out the line number code. Thank you beautiful work.

@emamut

This comment has been minimized.

Copy link

commented Sep 17, 2015

Works great in Ubuntu 14.04 Thanks a lot

@maekawatoshiki

This comment has been minimized.

Copy link

commented Sep 30, 2015

Thanks a lot!

@raphaelcasimir

This comment has been minimized.

Copy link

commented Jan 14, 2016

The fonts are not recognised for me, even if I use the powerline fonts... ubuntu 15.10 gnome shell...

@timbru31

This comment has been minimized.

Copy link

commented Jan 18, 2016

@raphaelcasimir I had issues with Menlo, too. Switched to this one for the symbols:
https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Hack

@smileart

This comment has been minimized.

Copy link
Owner Author

commented Jan 20, 2016

Now I use this font: http://sourcefoundry.org/hack/
Before I used this one: https://gist.github.com/smileart/9741746

@lborg019

This comment has been minimized.

Copy link

commented Feb 19, 2016

modified

Changed some symbol characters, now it works as it is supposed to (I am using powerline font on iTerm 2).
@raphaelcasimir
If you are having issues like I had, try copy pasting this. Worked for me, hope it helps!

# Original theme https://github.com/agnoster zsh theme
# modified by lborg019

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
      FG_COLOR=black
    fi

    if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
        BG_COLOR=red
        FG_COLOR=white
    fi
    echo "%{%K{$BG_COLOR}%}%{%F{$FG_COLOR}%} $(_git_prompt_info) %{%F{$BG_COLOR}%K{blue}%}"
  else
    echo "%{%K{blue}%}"
  fi
}

function virtualenv_info {
    [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}

PROMPT_HOST='%{%b%F{gray}%K{black}%} %(?.%{%F{green}%}✔.%{%F{red}%}✘)%{%F{yellow}%} %n %{%F{black}%}'
PROMPT_DIR='%{%F{white}%} %~%  '
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
$(virtualenv_info)❯ '
RPROMPT='%{$fg[green]%}[%*]%{$reset_color%}'
@bmo-at

This comment has been minimized.

Copy link

commented Jan 24, 2018

@lborg019 Works very well! One question: I really like the display of the username, but i'd love it if the machine name would also be shown ( like this: ✔ username@hostmachine   master  ~/...). I'm just getting started with linux, could you show me how it's done?

@bepstein111

This comment has been minimized.

Copy link

commented May 10, 2019

First and third (arrow and branch) symbols appear as boxes on Mac OS Mojave with both Powerline Fonts and Nerd Fonts. Same config seems to be fine on my Windows machine. V strange.

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.