From 45e7a2fce43f868a26aead75aa3bfeea063e80f6 Mon Sep 17 00:00:00 2001 From: Benjamin Martinez Date: Fri, 8 Apr 2011 19:35:05 -0700 Subject: [PATCH] adde battery and archlinux plugin --- plugins/archlinux/archlinux.plugin.zsh | 57 +++++++++++++++++++++++++ plugins/battery/battery.plugin.zsh | 59 ++++++++++++++++++++++++++ themes/cruznick.zsh-theme | 36 ++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 plugins/archlinux/archlinux.plugin.zsh create mode 100644 plugins/battery/battery.plugin.zsh create mode 100644 themes/cruznick.zsh-theme diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh new file mode 100644 index 000000000..d26dddb96 --- /dev/null +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -0,0 +1,57 @@ +##some functions +############### +##--Daemons--## +############### +# starts, stops, restarts and check status of daemons + +dstart() { + for arg in $@ + do + sudo /etc/rc.d/$arg start + done +} +dstop() { + for arg in $@ + do + sudo /etc/rc.d/$arg stop + done +} +drestart() { + for arg in $@ + do + sudo /etc/rc.d/$arg restart + done +} +dstatus() { + for arg in $@ + do + sudo /etc/rc.d/$arg status + done +} + + +###Alias +## checks if pacman-color is installed +## pcman var is needed because for some reason using pacman-color with sudo in an alias doesnt work +if which pacman-color &>/dev/null; then + pcman='pacman-color' +else + pcman='pacman' +fi + +alias pacman='$pcman' +alias pacupd='_ $pcman -Syu' ##syncs and updates +alias pacser='$pcman -Ss' ##search repos for pkgs +alias pacins='_ $pcman -S' ##install pkgs +alias pacinf='$pcman -Qi' ##info of installed pkgs +alias paciss='$pcman -Qs' ##search installed pkgs +alias pacrm='_ $pcman -R' ##uninstalls pkgs +alias pacrmd='_ $pcman -Rs' ##remove a package and deps which are not required by any other installed package +alias pacrma='_ $pcman -Rsn' ##remove a package and deps and .pacsave files +alias pacclc='_ S $pcman -Scc' ## cleans pkgs cache and repos db +##makepkg alias +alias mksource='makepkg --source -f' +alias mkp='makepkg -sf ;alert' +alias mkpi='makepkg -sfi ' +alias mkall='makepkg -sf && makepkg --source -f ' +alias mkalli='makepkg -sfi && makepkg --source -f ' diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh new file mode 100644 index 000000000..6f7391b41 --- /dev/null +++ b/plugins/battery/battery.plugin.zsh @@ -0,0 +1,59 @@ +#!/bin/sh + +##defining path of battery +if [ -e /proc/acpi/battery/BAT0/ ] + then + battpath="/proc/acpi/battery/BAT0" +elif [ -e /proc/acpi/battery/BAT1/ ] + then + battpath="/proc/acpi/battery/BAT1" +else + echo "No battery found. Make sure that you have acpi support in your kernel" + echo "and that the computer actually is a laptop :)" + exit 1 +fi +batt_prompt_perc(){ +fullcap=`grep "^last full capacity" $battpath/info | awk '{ print $4 }'` +remcap=`grep "^remaining capacity" $battpath/state | awk '{ print $3 }'` + +charge=$(( $remcap * 100 / $fullcap )) + +# prevent a charge of more than 100% displaying +if [ "$charge" -gt "99" ] + then + charge=100 +fi + +color="red" +if [ $charge -gt "80" ] + then + color="cyan" +elif [ $charge -gt 60 ] + then + color="green" +elif [ $charge -gt 25 ] + then + color="yellow" +fi + +echo -e "%F{$color}$charge%f" +} + +bat_prompt_acstt(){ +batstate=`grep "^charging state" $battpath/state | awk '{ print $3 }'` +case "${batstate}" in + 'charged') + clr="green" + btst="°" + ;; + 'charging') + clr="blue" + btst="+" + ;; + 'discharging') + clr="yellow" + btst="-" + ;; +esac +echo -e "%F{$clr}$btst%f" +} diff --git a/themes/cruznick.zsh-theme b/themes/cruznick.zsh-theme new file mode 100644 index 000000000..9d558caf4 --- /dev/null +++ b/themes/cruznick.zsh-theme @@ -0,0 +1,36 @@ + +prompt_char() { + git branch >/dev/null 2>/dev/null && echo "%F{cyan}±%f" && return + hg root >/dev/null 2>/dev/null && echo "%F{cyan}☿%f" && return +} +custom_prompt_info() { + git branch >/dev/null 2>/dev/null && echo "$(git_prompt_info)%F{green}--%f[$(git_prompt_status)]" && return + hg root >/dev/null 2>/dev/null && hg prompt "{ on {branch}}{ at {bookmark}}{status}" 2> /dev/null && return + +} +command_succes() { +if [ $? = 0 ] +then + echo "%F{yellow}^_^%f" +else + echo "%F{red}O_O%f" +fi +} + +PROMPT='┌[%F{green}%3c%f] $(custom_prompt_info) +%F{white}└%f %F{green}%#%f >> ' +RPROMPT='$(command_succes) $(batt_prompt_perc)$(bat_prompt_acstt) $(prompt_char)' + + +ZSH_THEME_GIT_PROMPT_PREFIX="[%F{yellow}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%f]" +ZSH_THEME_GIT_PROMPT_DIRTY=" %F{red}*%f" +ZSH_THEME_GIT_PROMPT_CLEAN=" %F{green}°%f" + +ZSH_THEME_GIT_PROMPT_ADDED="%F{green}+%f" +ZSH_THEME_GIT_PROMPT_MODIFIED="%F{blue}*%f" +ZSH_THEME_GIT_PROMPT_DELETED="%F{red}x%f" +ZSH_THEME_GIT_PROMPT_RENAMED="%F{magenta}->%f" +ZSH_THEME_GIT_PROMPT_UNMERGED="%F{yellow}═%f" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%F{cyan}?%f" +