From 09f16a6255ebd12bfab271c34edb4a2cdf0079f4 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 28 Feb 2013 17:19:38 -0800 Subject: [PATCH 1/5] Adding copy of agnoster theme for Powerline beta support --- themes/agnoster_beta.zsh-theme | 115 +++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 themes/agnoster_beta.zsh-theme diff --git a/themes/agnoster_beta.zsh-theme b/themes/agnoster_beta.zsh-theme new file mode 100644 index 000000000..c3107c06c --- /dev/null +++ b/themes/agnoster_beta.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 black default "%(!.%{%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 blue black '%~' +} + +# 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) ' From a1352456bc13bd2d892c36aa7ed17e63c1e0d775 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 28 Feb 2013 17:22:39 -0800 Subject: [PATCH 2/5] Fixing glyphs for new Powerline characters (Lokaltog/powerline) Latest patched fonts do not support previous agnoster theme. This patch repalces them with the new unicode glyphs. --- themes/agnoster_beta.zsh-theme | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/agnoster_beta.zsh-theme b/themes/agnoster_beta.zsh-theme index c3107c06c..4f832ec97 100644 --- a/themes/agnoster_beta.zsh-theme +++ b/themes/agnoster_beta.zsh-theme @@ -26,7 +26,8 @@ # A few utility functions to make it easy and re-usable to draw segmented prompts CURRENT_BG='NONE' -SEGMENT_SEPARATOR='⮀' +SEGMENT_SEPARATOR='' +BRANCH_SYMBOL='' # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, @@ -79,7 +80,7 @@ prompt_git() { else prompt_segment green black fi - echo -n "${ref/refs\/heads\//⭠ }$dirty" + echo -n "${ref/refs\/heads\//$BRANCH_SYMBOL }$dirty" fi } From 0fe05e24db1584feb98b389f7613b70c233ecd2a Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Sun, 31 Mar 2013 08:21:47 +0400 Subject: [PATCH 3/5] Adding basic fortune plugin --- plugins/fortune/fortune.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/fortune/fortune.plugin.zsh diff --git a/plugins/fortune/fortune.plugin.zsh b/plugins/fortune/fortune.plugin.zsh new file mode 100644 index 000000000..25a7c5193 --- /dev/null +++ b/plugins/fortune/fortune.plugin.zsh @@ -0,0 +1,4 @@ +if type fortune &> /dev/null; then + fortune + echo +fi From b6299678b26b193a59f00f9dd8688f1039fea726 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Sun, 31 Mar 2013 08:23:06 +0400 Subject: [PATCH 4/5] Adding gnu-colors plugin for dir_colors and list-colors --- plugins/gnu-colors/gnu-colors.plugin.zsh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/gnu-colors/gnu-colors.plugin.zsh diff --git a/plugins/gnu-colors/gnu-colors.plugin.zsh b/plugins/gnu-colors/gnu-colors.plugin.zsh new file mode 100644 index 000000000..fe5293eef --- /dev/null +++ b/plugins/gnu-colors/gnu-colors.plugin.zsh @@ -0,0 +1,6 @@ +if type dircolors &> /dev/null; then + eval `dircolors ~/.dir_colors` +fi + +# Temporary workaround for tab completion LS_COLORS; Issue #1563 +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} From f29f4a0b77a74cf2540480529addf9d7a04fa340 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Sun, 31 Mar 2013 09:39:16 +0400 Subject: [PATCH 5/5] Updating to use xterm-256color --- plugins/tmux/tmux.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 465f5b053..4091fae35 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -21,7 +21,7 @@ if which tmux &> /dev/null # The TERM to use for 256 color terminals. # Tmux states this should be screen-256color, but you may need to change it on # systems without the proper terminfo - [[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color" + [[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="xterm-256color" # Get the absolute path to the current directory