From 2bec4fe5fe5145fcd3ad447d3a86b084eab5cfae Mon Sep 17 00:00:00 2001 From: Nate Soares Date: Mon, 23 Jan 2012 23:46:03 -0800 Subject: [PATCH] Created so8res theme This is a multi-line prompt theme. It's based off of Steve Losh's [Extravagent Zsh](http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt) prompt. It has the usual cool git features (and can be used with the untracked pull request that I made), but the coolest feature is probably the battery life meter. I use `acpi -b` to find battery info and display information accordingly. You may need to modify the battery_* functions on your own to get it to work on your machine, but it should work in the general case. --- themes/so8res.zsh-theme | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 themes/so8res.zsh-theme diff --git a/themes/so8res.zsh-theme b/themes/so8res.zsh-theme new file mode 100644 index 000000000..b8da08fb8 --- /dev/null +++ b/themes/so8res.zsh-theme @@ -0,0 +1,60 @@ +function collapse_pwd { + echo $(pwd | sed -e "s,^$HOME,~,") +} +function prompt_char { + git branch >/dev/null 2>/dev/null && echo 'ยป' && return + hg root >/dev/null 2>/dev/null && echo 'โ‡’' && return + echo 'โ†’' +} +function battery_charging { + if [[ $(acpi -b) == *Discharging* ]] ; then echo 0; else echo 1; fi +} +function battery_charge { + echo $(acpi -b | sed 's/.*, \([0-9]\+\).*/\1/') +} +function battery_mode { + if [[ $(battery_charging) -eq 1 ]] ; then + echo "%{$fg[blue]%}" + elif [[ $(battery_charge) -ge 70 ]] ; then + echo "%{$fg[green]%}" + elif [[ $(battery_charge) -ge 30 ]] ; then + echo "%{$fg[yellow]%}" + elif [[ $(battery_charge) -ge 12 ]] ; then + echo "%{$fg[red]%}%B" + else + echo "%{$fg[red]%}%S%B" + fi +} +function battery_info { + if [[ $(battery_charging) -eq 1 ]] ; then + if [[ $(battery_charge) -lt 98 ]] ; then + echo "["$(battery_charge)"%%]" + fi + else + echo "["$(battery_charge)"%%]" + fi +} + +COLOR_NAME='%{$fg[magenta]%}' +COLOR_HOST='%{$fg[yellow]%}' +COLOR_DIR='%{$fg[green]%}' +COLOR_ARROW='%{$fg[cyan]%}' + +COLOR_DAYNAME='%{$fg[magenta]%}' +COLOR_DAYNUM='%{$fg[magenta]%}%B' +COLOR_MONTH='%{$fg[yellow]%}%b' +COLOR_TIME='%{$fg[green]%}' + +COLOR_RESET='%{$reset_color%}%s%u%b' +COLOR_SPACE='%{$fg[white]%}' + +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[magenta]%}"'*' +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}"' โœ”' + +RPROMPT=$COLOR_DAYNAME\$(date +"%a")' '$COLOR_DAYNUM\$(date +"%d")' '$COLOR_MONTH\$(date +"%b")' '$COLOR_TIME\$(date +"%H:%M")' '\$(battery_mode)\$(battery_info)$COLOR_RESET + +PROMPT=$COLOR_NAME'%n'$COLOR_SPACE'@'$COLOR_HOST'%m'$COLOR_SPACE':'$COLOR_DIR\$(collapse_pwd)\$(git_prompt_info)$COLOR_ARROW' +'\$(prompt_char)' '$COLOR_RESET