From d6c66933acbcb811e1374f24dfd145098bb327c7 Mon Sep 17 00:00:00 2001 From: Jannis Hermanns Date: Tue, 4 Dec 2012 20:09:54 +0100 Subject: [PATCH 1/6] My fino --- themes/fino-jannis.zsh-theme | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 themes/fino-jannis.zsh-theme diff --git a/themes/fino-jannis.zsh-theme b/themes/fino-jannis.zsh-theme new file mode 100644 index 000000000..75b435152 --- /dev/null +++ b/themes/fino-jannis.zsh-theme @@ -0,0 +1,39 @@ +# Fino-time theme by Aexander Berezovsky (http://berezovsky.me) based on Fino by Max Masnick (http://max.masnick.me) + +# Use with a dark background and 256-color terminal! +# Meant for people with RVM and git. Tested only on OS X 10.7. + +# You can set your computer name in the ~/.box-name file if you want. + +# Borrowing shamelessly from these oh-my-zsh themes: +# bira +# robbyrussell +# +# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ + +function virtualenv_info { + [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' +} + +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '⠠⠵' && return + echo '○' +} + +function box_name { + [ -f ~/.box-name ] && cat ~/.box-name || hostname -s +} + + +local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}' +local current_dir='${PWD/#$HOME/~}' +local git_info='$(git_prompt_info)' + + +PROMPT="╭─ {$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby} %{$FG[239]%}with %{$reset_color%}$(battery_time_remaining) %{$FG[239]%}left %{$reset_color%} +╰─$(virtualenv_info)$(prompt_char) " + +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$FG[202]%}✘" +ZSH_THEME_GIT_PROMPT_CLEAN=" %{$FG[040]%}✔" From a0a21e43ea085b9b85e14492db908cc2098e220c Mon Sep 17 00:00:00 2001 From: Jannis Hermanns Date: Tue, 4 Dec 2012 20:10:48 +0100 Subject: [PATCH 2/6] Almost gutt --- themes/fino-jannis.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/fino-jannis.zsh-theme b/themes/fino-jannis.zsh-theme index 75b435152..1a1665451 100644 --- a/themes/fino-jannis.zsh-theme +++ b/themes/fino-jannis.zsh-theme @@ -30,7 +30,7 @@ local current_dir='${PWD/#$HOME/~}' local git_info='$(git_prompt_info)' -PROMPT="╭─ {$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby} %{$FG[239]%}with %{$reset_color%}$(battery_time_remaining) %{$FG[239]%}left %{$reset_color%} +PROMPT="╭─ $reset_color%}%{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby} %{$FG[239]%}with %{$reset_color%}$(battery_time_remaining) %{$FG[239]%}left %{$reset_color%} ╰─$(virtualenv_info)$(prompt_char) " ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" From 107f5574384e7faeb1dc01311a59f1dcc2d3d8e7 Mon Sep 17 00:00:00 2001 From: Jannis Hermanns Date: Wed, 5 Dec 2012 15:01:05 +0100 Subject: [PATCH 3/6] Added time --- themes/fino-jannis.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/fino-jannis.zsh-theme b/themes/fino-jannis.zsh-theme index 1a1665451..9f2fb0389 100644 --- a/themes/fino-jannis.zsh-theme +++ b/themes/fino-jannis.zsh-theme @@ -30,7 +30,7 @@ local current_dir='${PWD/#$HOME/~}' local git_info='$(git_prompt_info)' -PROMPT="╭─ $reset_color%}%{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby} %{$FG[239]%}with %{$reset_color%}$(battery_time_remaining) %{$FG[239]%}left %{$reset_color%} +PROMPT="╭─ $reset_color%}%{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby}%{$FG[239]%} at%{$reset_color%}%t%{$FG[239]%} with %{$reset_color%}$(battery_time_remaining) %{$FG[239]%}left %{$reset_color%} ╰─$(virtualenv_info)$(prompt_char) " ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" From 8728b49acad97a7ae4449b9ee90effe95f8e643f Mon Sep 17 00:00:00 2001 From: Jannis Hermanns Date: Tue, 11 Dec 2012 10:53:29 +0100 Subject: [PATCH 4/6] Agnoster and fino update --- themes/agnoster-jannis.zsh-theme | 131 +++++++++++++++++++++++++++++++ themes/fino-jannis.zsh-theme | 13 ++- 2 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 themes/agnoster-jannis.zsh-theme diff --git a/themes/agnoster-jannis.zsh-theme b/themes/agnoster-jannis.zsh-theme new file mode 100644 index 000000000..4e9c48b39 --- /dev/null +++ b/themes/agnoster-jannis.zsh-theme @@ -0,0 +1,131 @@ +# Jannis' stuff +function bat { + echo "%{$FG[243]%}`battery_time_remaining`%{$reset_color%}" + # echo `date` +} +function virtualenv_info { + [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' +} +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '⠠⠵' && return + echo '○' +} + +# 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%}" + echo -n "\n╰─$(virtualenv_info)${$(prompt_char)} " + 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}%}$RETVAL" + [[ $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=$? + echo -n '╭─ ' # Jannis' + prompt_status + # prompt_context # Jannis' + prompt_dir + prompt_git + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt)' +RPROMPT='$(bat)' diff --git a/themes/fino-jannis.zsh-theme b/themes/fino-jannis.zsh-theme index 9f2fb0389..4d239b4ce 100644 --- a/themes/fino-jannis.zsh-theme +++ b/themes/fino-jannis.zsh-theme @@ -24,14 +24,23 @@ function box_name { [ -f ~/.box-name ] && cat ~/.box-name || hostname -s } +function bat { + echo `battery_time_remaining` +} local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}' local current_dir='${PWD/#$HOME/~}' local git_info='$(git_prompt_info)' +local pc='$(prompt_char)' -PROMPT="╭─ $reset_color%}%{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby}%{$FG[239]%} at%{$reset_color%}%t%{$FG[239]%} with %{$reset_color%}$(battery_time_remaining) %{$FG[239]%}left %{$reset_color%} -╰─$(virtualenv_info)$(prompt_char) " +# with host +# PROMPT="╭─ $reset_color%}%{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}${current_dir}%{$reset_color%}${git_info} %{$FG[239]%}using%{$FG[243]%} ${rvm_ruby}%{$FG[239]%} at %{$reset_color%}%t%{$FG[239]%}%{$reset_color%} +# ╰─$(virtualenv_info)${pc} " + +PROMPT="╭─ $reset_color%}%{$FG[033]%}%{$terminfo[bold]$FG[033]%}${current_dir}%{$reset_color%}${git_info} %{$FG[243]%}${rvm_ruby}%{$FG[239]%} at %{$reset_color%}%t%{$FG[239]%}%{$reset_color%} +╰─$(virtualenv_info)${pc} " +RPROMPT='$(bat)' ZSH_THEME_GIT_PROMPT_PREFIX=" %{$FG[239]%}on%{$reset_color%} %{$fg[255]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" From 5b7ded90a068075392590b06d627c92f0b6a94af Mon Sep 17 00:00:00 2001 From: Jannis Hermanns Date: Tue, 11 Dec 2012 11:06:38 +0100 Subject: [PATCH 5/6] Agnosting out --- themes/agnoster-jannis.zsh-theme | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/themes/agnoster-jannis.zsh-theme b/themes/agnoster-jannis.zsh-theme index 4e9c48b39..0e0d7ad8d 100644 --- a/themes/agnoster-jannis.zsh-theme +++ b/themes/agnoster-jannis.zsh-theme @@ -3,6 +3,9 @@ function bat { echo "%{$FG[243]%}`battery_time_remaining`%{$reset_color%}" # echo `date` } +function rvm_ruby { + echo "%{$FG[243]%}‹$(rvm-prompt i v g)›%{$reset_color%} " +} function virtualenv_info { [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' } @@ -65,7 +68,7 @@ prompt_end() { echo -n "%{%k%}" fi echo -n "%{%f%}" - echo -n "\n╰─$(virtualenv_info)${$(prompt_char)} " + # echo -n "\n╰─$(virtualenv_info)${$(prompt_char)} " CURRENT_BG='' } @@ -85,7 +88,7 @@ prompt_context() { prompt_git() { local ref dirty if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then - ZSH_THEME_GIT_PROMPT_DIRTY='±' + ZSH_THEME_GIT_PROMPT_DIRTY=" %{$FG[202]%}✘" 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 @@ -99,7 +102,8 @@ prompt_git() { # Dir: current working directory prompt_dir() { - prompt_segment blue black '%~' + # prompt_segment blue black '%~' + prompt_segment blue black '%1~' } # Status: @@ -119,7 +123,7 @@ prompt_status() { ## Main prompt build_prompt() { RETVAL=$? - echo -n '╭─ ' # Jannis' + # echo -n '╭─ ' # Jannis' prompt_status # prompt_context # Jannis' prompt_dir @@ -127,5 +131,5 @@ build_prompt() { prompt_end } -PROMPT='%{%f%b%k%}$(build_prompt)' -RPROMPT='$(bat)' +PROMPT='%{%f%b%k%}$(build_prompt) ' +RPROMPT='$(rvm_ruby)$(bat)' From 63f8146576c291d533bb2ebd253c59403ed92f07 Mon Sep 17 00:00:00 2001 From: Jannis Hermanns Date: Tue, 11 Dec 2012 19:15:03 +0100 Subject: [PATCH 6/6] Zero pad minutes in battery time remaining --- plugins/battery/battery.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 95f890632..02a7ebd9b 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -24,7 +24,8 @@ if [[ $(uname) == "Darwin" ]] ; then function battery_time_remaining() { if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then timeremaining=$(ioreg -rc "AppleSmartBattery"| grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') - echo "~$((timeremaining / 60)):$((timeremaining % 60))" + minutes="$((timeremaining % 60))" + echo "~$((timeremaining / 60)):${(l:2::0:)minutes}" else echo "∞" fi