Created
May 6, 2014 09:26
-
-
Save devnore/11557060 to your computer and use it in GitHub Desktop.
zsh-theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ $UID -eq 0 ]; then | |
NCOLOR="red"; | |
else | |
if [[ $(uname) == "Darwin" ]] ; then | |
NCOLOR="white"; | |
elif [[ $(uname) == "Linux" ]] ; then | |
NCOLOR="green" | |
fi | |
fi | |
function battery_pct_simon() { | |
if [[ $(uname -s) == 'Darwin' ]]; then | |
echo $(pmset -g batt | grep -o "[0-9]*%" | tr -d '%') | |
elif [[ $(uname -s) == 'Linux' ]]; then | |
echo $(battery_pct) | |
fi | |
} | |
function has_battery() { | |
if [[ $(uname -s) == 'Darwin' ]]; then | |
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"FullyCharged"\ =\ ' | sed -e 's/^.*"FullyCharged"\ =\ //') == "Yes" ]] | |
elif [[ $(uname -s) == 'Linux' ]]; then | |
[[ -e /sys/class/power_supply/BAT0/info ]] | |
fi | |
} | |
function battery_is_full() { | |
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"FullyCharged"\ =\ ' | sed -e 's/^.*"FullyCharged"\ =\ //') == "Yes" ]] | |
} | |
function battery_charge { | |
local disabled=${BATTERY_DISABLED:0} | |
local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; | |
local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; | |
local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; | |
local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; | |
local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; | |
local color_red=${BATTERY_COLOR_RED:-%F{red}}; | |
local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; | |
local battery_prefix=${BATTERY_GAUGE_PREFIX:-''}; | |
local battery_suffix=${BATTERY_GAUGE_SUFFIX:-''}; | |
local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'â–¸'}; | |
local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'â–¹'}; | |
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; | |
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'âš¡'}; | |
local discharging_symbol=${BATTERY_DISCHARGING_SYMBOL:-'🔋'}; | |
local full_symbol=${BATTERY_FULL_SYMBOL:-' 🔌'}; | |
if [[ $(has_battery) == 1 ]]; then | |
local disabled=1 | |
fi | |
#Temporary hack until i get the has_battery function working on linux. | |
if [[ $(uname) == "Linux" ]] ; then | |
local disabled=1 | |
fi | |
battery_remaining_percentage=$(battery_pct_simon) | |
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then | |
local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); | |
local empty=$(($gauge_slots - $filled)); | |
local gauge_color=$color_green; | |
if [[ $filled -gt $green_threshold ]]; then | |
local gauge_color=$color_green; | |
elif [[ $filled -gt $yellow_threshold ]]; then | |
local gauge_color=$color_yellow; | |
else | |
local gauge_color=$color_red; | |
fi | |
else | |
local filled=$gauge_slots; | |
local empty=0; | |
filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; | |
fi | |
if $(battery_is_charging); then | |
local charging=$charging_symbol | |
elif $(battery_is_full); then | |
local charging=$full_symbol | |
else | |
local charging=$discharging_symbol | |
fi | |
if [[ $disabled -eq 1 ]]; then | |
# Abstract this to allow use of custon texts as alternate | |
echo -n '[' | |
if [[ $(uname) == "Darwin" ]] ; then | |
echo -n "Not implemented" | |
elif [[ $(uname) == "Linux" ]] ; then | |
echo -n `/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` | |
fi | |
echo "][%*]" | |
return 0 | |
else | |
printf ${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} | |
printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} | |
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} | |
printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%}${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%} | |
return 0 | |
fi | |
} | |
PROMPT='%{$fg[$NCOLOR]%}%B%n@%M%b%{$reset_color%}:%{$fg[blue]%}%B%c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) ' | |
RPROMPT='$(battery_charge)' | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg_no_bold[yellow]%}%B" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%b%{$fg_bold[blue]%})%{$reset_color%} " | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}✗" | |
export LSCOLORS="Gxfxcxdxbxegedabagacad" | |
export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment