From dbdd23d0fa1309444d01d7540a0f3065d514e741 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Donoso Date: Fri, 13 Dec 2013 19:05:35 -0300 Subject: [PATCH 1/5] Prevents oh-my-zsh loading the .zshenv twice --- oh-my-zsh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 2ae07668c..3c0f4f8f5 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,6 +1,6 @@ # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then - /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh + /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh From b58b996b40f8de1f030d59336e3594b63ef598ee Mon Sep 17 00:00:00 2001 From: lumbric Date: Sat, 21 Dec 2013 19:49:44 +0100 Subject: [PATCH 2/5] fix name schema for sudo plugin Plugin won't load automatically if added to variable $plugins, if name schema different than $name/$name.plugin.zsh is used (see is_plugin() in oh-my-zsh.sh). --- plugins/sudo/{sudo.zsh => sudo.plugin.zsh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/sudo/{sudo.zsh => sudo.plugin.zsh} (100%) diff --git a/plugins/sudo/sudo.zsh b/plugins/sudo/sudo.plugin.zsh similarity index 100% rename from plugins/sudo/sudo.zsh rename to plugins/sudo/sudo.plugin.zsh From cc8b09366b62d8f260e1cdd3d4a1acd868e5c9e0 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Mon, 6 Jan 2014 02:09:15 +0100 Subject: [PATCH 3/5] Adds a method that print a battery gauge It is especially useful for themes, this function is a port of the code written by Steve Losh and made available on [this blog entry](http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/#my-right-prompt-battery-capacity) --- plugins/battery/battery.plugin.zsh | 80 ++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 9f053383a..16ad3e651 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -11,8 +11,9 @@ if [[ $(uname) == "Darwin" ]] ; then function battery_pct() { - typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') - typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') + local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" + typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') + typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') integer i=$(((currentcapacity/maxcapacity) * 100)) echo $i } @@ -26,8 +27,9 @@ 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"\ =\ //') + local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" + if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then + timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') echo "~$((timeremaining / 60)):$((timeremaining % 60))" else echo "∞" @@ -49,6 +51,10 @@ if [[ $(uname) == "Darwin" ]] ; then echo "∞" fi } + + function battery_is_charging() { + [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] + } elif [[ $(uname) == "Linux" ]] ; then @@ -79,14 +85,66 @@ elif [[ $(uname) == "Linux" ]] ; then echo "∞" fi } + + function battery_pct() { + # todo for on linux + } + + function battery_is_charging() { + # todo on linux + false + } + else - # Empty functions so we don't cause errors in prompts - function battery_pct_remaining() { - } + # Empty functions so we don't cause errors in prompts + function battery_pct_remaining() { + } - function battery_time_remaining() { - } + function battery_time_remaining() { + } - function battery_pct_prompt() { - } + function battery_pct_prompt() { + } fi + +function battery_level_gauge() { + 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 battery_remaining_percentage=$(battery_pct); + + if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then + local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); + local empty=$(($gauge_slots - $filled)); + + 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 + + + local charging=' ' && battery_is_charging && charging=$charging_symbol; + + printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${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//\%/\%\%} +} + + From 9b3344dd8085bdcb16d08b5e47492b275e44955e Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Thu, 23 Jan 2014 20:58:23 -0800 Subject: [PATCH 4/5] change nyancat telnet server miku.acm.uiuc.edu was decommissioned a while ago; this is a sanctioned mirror --- plugins/nyan/nyan.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nyan/nyan.plugin.zsh b/plugins/nyan/nyan.plugin.zsh index 6321e5f5a..af01c9605 100644 --- a/plugins/nyan/nyan.plugin.zsh +++ b/plugins/nyan/nyan.plugin.zsh @@ -1,5 +1,5 @@ if [[ -x `which nc` ]]; then - alias nyan='nc -v miku.acm.uiuc.edu 23' # nyan cat + alias nyan='nc -v nyan.howes.net.nz 23' # nyan cat fi From a48fd1e80882e1f3008d5ee027b3e41d38844414 Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Fri, 24 Jan 2014 10:27:41 -0800 Subject: [PATCH 5/5] Update nyan.plugin.zsh --- plugins/nyan/nyan.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nyan/nyan.plugin.zsh b/plugins/nyan/nyan.plugin.zsh index af01c9605..ac9d0017e 100644 --- a/plugins/nyan/nyan.plugin.zsh +++ b/plugins/nyan/nyan.plugin.zsh @@ -1,5 +1,5 @@ if [[ -x `which nc` ]]; then - alias nyan='nc -v nyan.howes.net.nz 23' # nyan cat + alias nyan='nc -v nyancat.dakko.us 23' # nyan cat fi