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%}"