Skip to content
This repository

new theme, gnosis #569

Closed
wants to merge 1 commit into from

2 participants

Gary V. Vaughan Robby Russell
Gary V. Vaughan

terminal width prompt with git details, and warnings about suspended
jobs, and non-zero exit status

screenshots available on request

Gary V. Vaughan new theme, gnosis
terminal width prompt with git details, and warnings about suspended
jobs, and non-zero exit status
c46f33b
Robby Russell

Thanks for sending this across. However, at this point in time... I am not going to be accepting any new themes for a while. My aim is to work out a new solution for how to manage user theme contributions better in the future, but am thinking that 100+ is already too many for folks to browse/select from. :-)

Be sure to follow @ohmyzsh on twitter ( http://twitter.com/ohmyzsh ) to stay tuned for when we might have a good location for such themes.

ProTip: If you have a custom theme and want to use it... you might check out this (poorly documented) feature from pull-request #1111.

Robby Russell robbyrussell closed this December 02, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 23, 2011
Gary V. Vaughan new theme, gnosis
terminal width prompt with git details, and warnings about suspended
jobs, and non-zero exit status
c46f33b
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 134 additions and 0 deletions. Show diff stats Hide diff stats

  1. 134  themes/gnosis.zsh-theme
134  themes/gnosis.zsh-theme
... ...
@@ -0,0 +1,134 @@
  1
+# Some colors
  2
+# -----------
  3
+# Expand these right away, to minimise cycles spent expanding every prompt!
  4
+# You can override these before loading the theme.
  5
+: ${GNOSIS_C1="%{$reset_color$fg[blue]%}"}
  6
+: ${GNOSIS_C2="%{$reset_color$fg_bold[green]%}"}
  7
+: ${GNOSIS_C3="%{$reset_color$fg[cyan]%}"}
  8
+: ${GNOSIS_ACCENT1="%{$reset_color$fg[yellow]%}"}
  9
+: ${GNOSIS_ACCENT2="%{$reset_color$fg_bold[white]%}"}
  10
+: ${GNOSIS_STANDOUT="%{$fg_bold[red]%}"}
  11
+
  12
+# Use ACS if the terminal supports that
  13
+typeset -A altchar
  14
+set -A altchar ${(s..)terminfo[acsc]}
  15
+
  16
+
  17
+# Some graphics
  18
+# -------------
  19
+# Not forgetting to set some fallbacks for non-ACS capable terminals.
  20
+# You can override these before loading too.
  21
+: ${GNOSIS_ACS_HLINE="${altchar[q]:--}"}
  22
+: ${GNOSIS_ACS_VLINE="${altchar[x]:-|}"}
  23
+: ${GNOSIS_ACS_LRCORNER="${altchar[j]:-\'}"}
  24
+: ${GNOSIS_ACS_URCORNER="${altchar[k]:-.}"}
  25
+: ${GNOSIS_ACS_ULCORNER="${altchar[l]:-,}"}
  26
+: ${GNOSIS_ACS_LLCORNER="${altchar[m]:-\`}"}
  27
+: ${GNOSIS_ACS_LTEE="${altchar[t]:-|}"}
  28
+: ${GNOSIS_ACS_RTEE="${altchar[u]:-|}"}
  29
+
  30
+
  31
+# Prompt fragments
  32
+# ----------------
  33
+# More early expansion where you can override things before loading.
  34
+: ${GNOSIS_PREFIX1="%{$terminfo[enacs]$terminfo[smacs]%}$GNOSIS_ACS_ULCORNER$GNOSIS_ACS_HLINE$GNOSIS_ACS_RTEE%{$terminfo[rmacs]%}"}
  35
+: ${GNOSIS_PREFIX2="%{$terminfo[smacs]%}$GNOSIS_ACS_LTEE%{$terminfo[rmacs]%}"}
  36
+: ${GNOSIS_SEP="%{$reset_color$terminfo[smacs]%}$GNOSIS_ACS_VLINE%{$terminfo[rmacs]%}"}
  37
+
  38
+# Format for git_prompt_info()
  39
+ZSH_THEME_GIT_PROMPT_PREFIX=$GNOSIS_SEP
  40
+ZSH_THEME_GIT_PROMPT_SUFFIX=%{$reset_color%}
  41
+
  42
+# Format for parse_git_dirty()
  43
+ZSH_THEME_GIT_PROMPT_DIRTY=$GNOSIS_STANDOUT
  44
+ZSH_THEME_GIT_PROMPT_CLEAN=$GNOSIS_ACCENT2
  45
+
  46
+# Format for git_prompt_status()
  47
+ZSH_THEME_GIT_PROMPT_ADDED="${GNOSIS_C1}+"
  48
+ZSH_THEME_GIT_PROMPT_MODIFIED="${GNOSIS_C2}*"
  49
+ZSH_THEME_GIT_PROMPT_RENAMED="${GNOSIS_C3}!"
  50
+ZSH_THEME_GIT_PROMPT_UNTRACKED="${GNOSIS_ACCENT1}?"
  51
+ZSH_THEME_GIT_PROMPT_DELETED="${GNOSIS_ACCENT2}-"
  52
+ZSH_THEME_GIT_PROMPT_UNMERGED="${GNOSIS_STANDOUT}<"
  53
+
  54
+# Format for git_prompt_ahead()
  55
+ZSH_THEME_GIT_PROMPT_AHEAD="${GNOSIS_STANDOUT}>"
  56
+
  57
+# Format for git_prompt_long_sha() and git_prompt_short_sha()
  58
+ZSH_THEME_GIT_PROMPT_SHA_BEFORE=$GNOSIS_SEP$GNOSIS_ACCENT1
  59
+ZSH_THEME_GIT_PROMPT_SHA_AFTER=%{$reset_color%}$GNOSIS_SEP
  60
+
  61
+
  62
+# precmd ()
  63
+# ---------
  64
+# Recalculate terminal width and padding before every prompt!
  65
+function precmd {
  66
+    local TERMWIDTH
  67
+    (( TERMWIDTH = $COLUMNS - 1 ))	# RPROMPT leaves one space unused
  68
+
  69
+    # Truncate the path if it's too long
  70
+    GNOSIS_PAD=0
  71
+    GNOSIS_TILDELEN=''
  72
+
  73
+    promptstrip=$(echo "${(e):-$GNOSIS_LEFT$GNOSIS_RIGHT}" \
  74
+	|sed -e :a -e 's/%{[^}]*%}//g;/%{/N;//ba')
  75
+    promptsize=${#${(%):-$promptstrip}}
  76
+    pwdsize=${#${(%):-%~}}
  77
+
  78
+    if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
  79
+        (( GNOSIS_TILDELEN = $TERMWIDTH - $promptsize ))
  80
+    else
  81
+	(( GNOSIS_PAD = $TERMWIDTH - $promptsize - $pwdsize ))
  82
+    fi
  83
+}
  84
+
  85
+# git_prompt_info ()
  86
+# ------------------
  87
+# Overrides the oh-my-zsh definition to use $(parse_git_dirty) to change
  88
+# colors rather than print extra symbols.
  89
+function git_prompt_info() {
  90
+  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
  91
+  echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(parse_git_dirty)${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
  92
+}
  93
+
  94
+# gnosis_shlvl ()
  95
+# ---------------
  96
+# Show the value of $SHLVL if it is greater than 1.
  97
+function gnosis_shlvl {
  98
+    test 1 = "$SHLVL" && return
  99
+    echo "$GNOSIS_SEP$GNOSIS_ACCENT2^$SHLVL%{$reset_color%}"
  100
+}
  101
+
  102
+# gnosis_stopped_jobs ()
  103
+# ----------------------
  104
+# Show a reminder in the prompt if there are any stopped jobs still
  105
+# attached to the shell.
  106
+function gnosis_stopped_jobs {
  107
+    local stopped=`jobs -s | wc -l | sed 's| *||'`
  108
+    [ $stopped -gt 0 ] && print "$GNOSIS_SEP$GNOSIS_STANDOUT$stopped stopped%{$reset_color%}$GNOSIS_SEP"
  109
+}
  110
+
  111
+
  112
+## ------------- ##
  113
+## Prompt format ##
  114
+## ------------- ##
  115
+
  116
+# These two form the left and right sides of the second line of the
  117
+# prompt, their widths are counted so anything that might take up
  118
+# character cells needs to be in here, and not later.
  119
+#
  120
+# Note that the function calls are escaped, because we don't want
  121
+# to call them right now, but every time the prompt is displayed!
  122
+GNOSIS_LEFT="$GNOSIS_PREFIX1$GNOSIS_C1%n%{$reset_color%}@$GNOSIS_C1%m$GNOSIS_SEP"
  123
+GNOSIS_RIGHT=" \$(git_prompt_ahead)\$(git_prompt_status)\$(parse_git_dirty)\$(git_prompt_info)%{$reset_color%}\$(git_prompt_short_sha)"
  124
+
  125
+# Main prompt
  126
+# -----------
  127
+# Print GNOSIS_LEFT up against the left side of the terminal, and
  128
+# GNOSIS_RIGHT up against the right side with the current directory in
  129
+# the gap, adding any additional padding dynamically.
  130
+PROMPT="
  131
+$GNOSIS_LEFT$GNOSIS_C2%\$GNOSIS_TILDELEN<...<%~%<<%{$reset_color%}\${(l.\$GNOSIS_PAD.. .)}$GNOSIS_RIGHT
  132
+$GNOSIS_PREFIX2$GNOSIS_ACCENT1!%!\$(gnosis_shlvl)%(?,,$GNOSIS_SEP${GNOSIS_STANDOUT}?%?)%{$reset_color%}="
  133
+RPROMPT="$GNOSIS_STANDOUT\$(gnosis_stopped_jobs)%{$reset_color%}"
  134
+PS2="$GNOSIS_PREFIX2$GNOSIS_ACCENT1!%!%{$reset_color%}+${GNOSIS_C1}%_%{$reset_color%}="
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.