73f777053725ce61d6fada67ff3f174130dd8c94
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
2new file mode 100644
3index 0000000000000000000000000000000000000000..c3107c06c04fb42b0ca27b0a81b15854819969c6
4--- /dev/null
5+++ b/themes/agnoster.zsh-theme
6@@ -0,0 +1,115 @@
7+# vim:ft=zsh ts=2 sw=2 sts=2
8+#
9+# agnoster's Theme - https://gist.github.com/3712874
10+# A Powerline-inspired theme for ZSH
11+#
12+# # README
13+#
14+# In order for this theme to render correctly, you will need a
15+# [Powerline-patched font](https://gist.github.com/1595572).
16+#
17+# In addition, I recommend the
18+# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
19+# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
20+# it has significantly better color fidelity.
21+#
22+# # Goals
23+#
24+# The aim of this theme is to only show you *relevant* information. Like most
25+# prompts, it will only show git information when in a git working directory.
26+# However, it goes a step further: everything from the current user and
27+# hostname to whether the last call exited with an error to whether background
28+# jobs are running in this shell will all be displayed automatically when
29+# appropriate.
30+
31+### Segment drawing
32+# A few utility functions to make it easy and re-usable to draw segmented prompts
33+
34+CURRENT_BG='NONE'
35+SEGMENT_SEPARATOR='⮀'
36+
37+# Begin a segment
38+# Takes two arguments, background and foreground. Both can be omitted,
39+# rendering default background/foreground.
40+prompt_segment() {
41+ local bg fg
42+ [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
43+ [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
44+ if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
45+ echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
46+ else
47+ echo -n "%{$bg%}%{$fg%} "
48+ fi
49+ CURRENT_BG=$1
50+ [[ -n $3 ]] && echo -n $3
51+}
52+
53+# End the prompt, closing any open segments
54+prompt_end() {
55+ if [[ -n $CURRENT_BG ]]; then
56+ echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
57+ else
58+ echo -n "%{%k%}"
59+ fi
60+ echo -n "%{%f%}"
61+ CURRENT_BG=''
62+}
63+
64+### Prompt components
65+# Each component will draw itself, and hide itself if no information needs to be shown
66+
67+# Context: user@hostname (who am I and where am I)
68+prompt_context() {
69+ local user=`whoami`
70+
71+ if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
72+ prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
73+ fi
74+}
75+
76+# Git: branch/detached head, dirty status
77+prompt_git() {
78+ local ref dirty
79+ if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
80+ ZSH_THEME_GIT_PROMPT_DIRTY='±'
81+ dirty=$(parse_git_dirty)
82+ ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
83+ if [[ -n $dirty ]]; then
84+ prompt_segment yellow black
85+ else
86+ prompt_segment green black
87+ fi
88+ echo -n "${ref/refs\/heads\//⭠ }$dirty"
89+ fi
90+}
91+
92+# Dir: current working directory
93+prompt_dir() {
94+ prompt_segment blue black '%~'
95+}
96+
97+# Status:
98+# - was there an error
99+# - am I root
100+# - are there background jobs?
101+prompt_status() {
102+ local symbols
103+ symbols=()
104+ [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
105+ [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"