From f4c67f3ab98bf59db7ba8348d1684663f4b4249e Mon Sep 17 00:00:00 2001 From: John Griffiths Date: Thu, 1 Aug 2013 11:04:42 -0400 Subject: [PATCH] agnoster-light, amuse, powerline themes. --- themes/agnoster-light.zsh-theme | 115 ++++++++++++++++++++++++++++++++ themes/amuse.zsh-theme | 21 ++++++ themes/powerline.zsh-theme | 65 ++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100755 themes/agnoster-light.zsh-theme create mode 100644 themes/amuse.zsh-theme create mode 100755 themes/powerline.zsh-theme diff --git a/themes/agnoster-light.zsh-theme b/themes/agnoster-light.zsh-theme new file mode 100755 index 000000000..52edc80d4 --- /dev/null +++ b/themes/agnoster-light.zsh-theme @@ -0,0 +1,115 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +SEGMENT_SEPARATOR='⮀' + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment blue white "%(!.%{%F{yellow}%}.)$user@%m" + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + echo -n "${ref/refs\/heads\//⭠ }$dirty" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment white blue '%~' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +## Main prompt +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) ' diff --git a/themes/amuse.zsh-theme b/themes/amuse.zsh-theme new file mode 100644 index 000000000..548f6d39d --- /dev/null +++ b/themes/amuse.zsh-theme @@ -0,0 +1,21 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 + +rvm_current() { + rvm current 2>/dev/null +} + +rbenv_version() { + rbenv version 2>/dev/null | awk '{print $1}' +} + +PROMPT=' +%{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) ⌚ %{$fg_bold[red]%}%*%{$reset_color%} +$ ' + +ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}⭠ " +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +RPROMPT='%{$fg_bold[red]%}$(rbenv_version)%{$reset_color%}' diff --git a/themes/powerline.zsh-theme b/themes/powerline.zsh-theme new file mode 100755 index 000000000..8c644c6ec --- /dev/null +++ b/themes/powerline.zsh-theme @@ -0,0 +1,65 @@ +# FreeAgent puts the powerline style in zsh ! + +if [ "$POWERLINE_RIGHT_B" = "" ]; then + POWERLINE_RIGHT_B=%D{%H:%M:%S} +fi + +if [ "$POWERLINE_RIGHT_A" = "" ]; then + POWERLINE_RIGHT_A=%D{%Y-%m-%d} +fi + +POWERLINE_CURRENT_PATH="%d" + +if [ "$POWERLINE_FULL_CURRENT_PATH" = "" ]; then + POWERLINE_CURRENT_PATH="%1~" +fi + +POWERLINE_GIT_INFO_LEFT="" +POWERLINE_GIT_INFO_RIGHT="%F{red}"$'\u2b82'"%F{black}%K{red}"$'$(git_prompt_info)'" %f" +if [ "$POWERLINE_SHOW_GIT_ON_RIGHT" = "" ]; then + POWERLINE_GIT_INFO_LEFT=$'$(git_prompt_info)' + POWERLINE_GIT_INFO_RIGHT="" +fi + +POWERLINE_COLOR_BG_GRAY=%K{240} +POWERLINE_COLOR_BG_LIGHT_GRAY=%K{240} +POWERLINE_COLOR_BG_WHITE=%K{255} + +POWERLINE_COLOR_FG_GRAY=%F{240} +POWERLINE_COLOR_FG_LIGHT_GRAY=%F{240} +POWERLINE_COLOR_FG_WHITE=%F{255} + +GIT_DIRTY_COLOR=%F{133} +GIT_CLEAN_COLOR=%F{118} +GIT_PROMPT_INFO=%F{012} + +ZSH_THEME_GIT_PROMPT_PREFIX=" \u2b60 " +ZSH_THEME_GIT_PROMPT_SUFFIX="$GIT_PROMPT_INFO" +ZSH_THEME_GIT_PROMPT_DIRTY=" $GIT_DIRTY_COLOR✘" +ZSH_THEME_GIT_PROMPT_CLEAN=" $GIT_CLEAN_COLOR✔" + +ZSH_THEME_GIT_PROMPT_ADDED="%F{082}✚%f" +ZSH_THEME_GIT_PROMPT_MODIFIED="%F{166}✹%f" +ZSH_THEME_GIT_PROMPT_DELETED="%F{160}✖%f" +ZSH_THEME_GIT_PROMPT_RENAMED="%F{220]➜%f" +ZSH_THEME_GIT_PROMPT_UNMERGED="%F{082]═%f" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%F{190]✭%f" + +POWERLINE_SEC1_BG=%K{green} +POWERLINE_SEC1_FG=%F{green} +POWERLINE_SEC1_TXT=%F{black} +if [ "$POWERLINE_DETECT_SSH" != "" ]; then + if [ -n "$SSH_CLIENT" ]; then + POWERLINE_SEC1_BG=%K{red} + POWERLINE_SEC1_FG=%F{red} + POWERLINE_SEC1_TXT=%F{white} + fi +fi +PROMPT="$POWERLINE_SEC1_BG$POWERLINE_SEC1_TXT %n %k%f$POWERLINE_SEC1_FG%K{blue}"$'\u2b80'"%k%f%F{white}%K{blue} "$POWERLINE_CURRENT_PATH" "$POWERLINE_GIT_INFO_LEFT"%k%f%F{blue}"$'\u2b80'"%f " + +if [ "$POWERLINE_NO_BLANK_LINE" = "" ]; then + PROMPT=" +"$PROMPT +fi + +RPROMPT=$POWERLINE_GIT_INFO_RIGHT$POWERLINE_COLOR_FG_WHITE$'\u2b82'"%f$POWERLINE_COLOR_BG_WHITE $POWERLINE_COLOR_FG_GRAY$POWERLINE_RIGHT_B "$'\u2b82'"%f%k$POWERLINE_COLOR_BG_GRAY$POWERLINE_COLOR_FG_WHITE $POWERLINE_RIGHT_A %f%k"