ff780ba546dd17afe37f6683d771ea8e225ec841

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4371 from afh/pull/emotty_theme

Add emotty theme

Diff

  1diff --git a/themes/emotty.zsh-theme b/themes/emotty.zsh-theme
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..f646b2fa8f00d801030204ad14a7974dde06aa6b
  4--- /dev/null
  5+++ b/themes/emotty.zsh-theme
  6@@ -0,0 +1,99 @@
  7+#!/usr/bin/env zsh
  8+# ------------------------------------------------------------------------------
  9+#          FILE: emotty.zsh-theme
 10+#   DESCRIPTION: A varying emoji based theme
 11+#        AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
 12+#       VERSION: 1.0.0
 13+#       DEPENDS: emotty plugin
 14+#    RECOMMENDS: Hasklig font
 15+#
 16+# This theme shows a different emoji for each tty at the main prompt.
 17+#
 18+# There are pre-defined different emoji sets to choose from, e.g.:
 19+# emoji, stellar, floral, zodiac, love (see emotty plugin).
 20+# 
 21+# To choose a different emotty set than the default (emoji)
 22+# % export emotty_set=nature
 23+#
 24+# For the superuser (root) this theme shows a designated indicator
 25+# and switches the foreground color to red
 26+# (see root_prompt variable, default: skull).
 27+# But you are using sudo (8) instead of designated a root shell, right‽
 28+#
 29+# When logged in via SSH the main prompt also shows the user- and hostname.
 30+#
 31+# The exit status of the last failed command is displayed in the window title
 32+# along with an indicator (see warn_glyph variable, default: collision symbol).
 33+# To clear it just run: $NULL, true or :
 34+#
 35+# The right prompt shows the current working directory (3 levels up) in cyan.
 36+#
 37+# When in a git repository the main prompt shows the current branch name
 38+# with a branch indicator in yellow
 39+# (see vcs_branch_glyph variable, default: Hasklig branch glyph).
 40+#
 41+# If there are modified files the prompt switches to red and shows an unstaged
 42+# indicator (see vcs_unstaged_glyph variable, default: circled letter M).
 43+#
 44+# If there are staged files the prompt switches to green and shows an staged
 45+# indicator (see vcs_staged_glyph variable, default: high voltage sign).
 46+#
 47+# In a git repository the right prompt shows the repository name in bold and
 48+# prepends the current working directory subpath within the repository.
 49+#
 50+# When git currently performs an action such as merge or rebase, the action is
 51+# displayed in red instead of the branch name and a special action indicator
 52+# is shown (see vcs_action_glyph variable, default: chevron).
 53+# ------------------------------------------------------------------------------
 54+
 55+user_prompt="$(emotty)"
 56+root_prompt="$emoji[skull]"
 57+warn_prompt="$emoji[collision_symbol]"
 58+
 59+vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}"
 60+vcs_staged_glyph="%{$emoji[high_voltage_sign] %1G%}"
 61+vcs_branch_glyph=$(print -P $'\Ue0a0') #  
 62+vcs_action_glyph=$(print -P $'\U276f') # ❯
 63+
 64+red="$FG[001]"
 65+yellow="$FG[003]"
 66+green="$FG[002]"
 67+cyan="$FG[014]"
 68+
 69+prompt_glyph="%{%(#.${root_prompt}.${user_prompt})%1G%}"
 70+
 71+# Uncomment the next line if you also like to see the warn_prompt in the prompt on the right.
 72+#last_command_failed="%(?.. %F{red}%1{${warn_prompt} %1G%}%?%f)"
 73+
 74+
 75+setopt promptsubst
 76+
 77+autoload -U add-zsh-hook
 78+autoload -Uz vcs_info
 79+
 80+zstyle ':vcs_info:*' enable git #hg svn cvs
 81+zstyle ':vcs_info:*' get-revision false
 82+zstyle ':vcs_info:*' check-for-changes true
 83+zstyle ':vcs_info:git:*' unstagedstr "${red}${vcs_unstaged_glyph}"
 84+zstyle ':vcs_info:*' stagedstr "${green}${vcs_staged_glyph}"
 85+
 86+# %(K|F){color} set (back|fore)ground color
 87+# %(k|f) reset (back|fore)ground color
 88+zstyle ':vcs_info:*' max-exports 3
 89+zstyle ':vcs_info:*' nvcsformats "${prompt_glyph} " '%3~' ''
 90+zstyle ':vcs_info:*' formats "${yellow}%u%c%b${vcs_branch_glyph}%f" '%S|' "$FX[bold]%r$FX[no-bold]" 
 91+zstyle ':vcs_info:*' actionformats "${red}%K{white}%a${vcs_action_glyph}%k%f" '%S|' "$FX[bold]%r$FX[no-bold]"
 92+
 93+red_if_root="%(!.%F{red}.)"
 94+sshuser_on_host="${SSH_TTY:+%(!.$red.$yellow)%n@%m$reset_color}"
 95+
 96+PROMPT='${sshuser_on_host}${vcs_info_msg_0_}${red_if_root} '
 97+RPROMPT='${cyan}${vcs_info_msg_1_##.|}${vcs_info_msg_2_}%f${last_command_failed}'
 98+
 99+emotty_title() {
100+  title "${${?/[^0]*/$warn_prompt $?}/0/${prompt_glyph}}"
101+}
102+add-zsh-hook precmd emotty_title
103+add-zsh-hook precmd vcs_info
104+
105+# vim:ft=zsh ts=2 sw=2 sts=2