mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
Merge 186dd035ae into ec37c05cb3
This commit is contained in:
commit
90e071d5f6
5 changed files with 14 additions and 72 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Check for updates on initial load...
|
# Check for updates on initial load...
|
||||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||||
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
|
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initializes Oh My Zsh
|
# Initializes Oh My Zsh
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,8 @@
|
||||||
if [[ $(uname) == "Darwin" ]] ; then
|
if [[ $(uname) == "Darwin" ]] ; then
|
||||||
|
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
|
||||||
typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
|
typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
|
||||||
typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
|
|
||||||
integer i=$(((currentcapacity/maxcapacity) * 100))
|
integer i=$(((currentcapacity/maxcapacity) * 100))
|
||||||
echo $i
|
echo $i
|
||||||
}
|
}
|
||||||
|
|
@ -27,9 +26,8 @@ if [[ $(uname) == "Darwin" ]] ; then
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_time_remaining() {
|
function battery_time_remaining() {
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
||||||
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
|
timeremaining=$(ioreg -rc "AppleSmartBattery"| grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
||||||
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
|
||||||
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
|
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
|
||||||
else
|
else
|
||||||
echo "∞"
|
echo "∞"
|
||||||
|
|
@ -51,10 +49,6 @@ if [[ $(uname) == "Darwin" ]] ; then
|
||||||
echo "∞"
|
echo "∞"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_is_charging() {
|
|
||||||
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
elif [[ $(uname) == "Linux" ]] ; then
|
elif [[ $(uname) == "Linux" ]] ; then
|
||||||
|
|
||||||
|
|
@ -85,66 +79,14 @@ elif [[ $(uname) == "Linux" ]] ; then
|
||||||
echo "∞"
|
echo "∞"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct() {
|
|
||||||
# todo for on linux
|
|
||||||
}
|
|
||||||
|
|
||||||
function battery_is_charging() {
|
|
||||||
# todo on linux
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Empty functions so we don't cause errors in prompts
|
# Empty functions so we don't cause errors in prompts
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_time_remaining() {
|
function battery_time_remaining() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct_prompt() {
|
function battery_pct_prompt() {
|
||||||
}
|
}
|
||||||
fi
|
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//\%/\%\%}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
|
||||||
# check again if another agent is running using the newly sourced settings
|
# check again if another agent is running using the newly sourced settings
|
||||||
if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
|
if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
|
||||||
# check for existing ssh-agent
|
# check for existing ssh-agent
|
||||||
if ssh-add -l > /dev/null 2> /dev/null; then
|
if [[ -n $SSH_AUTH_SOCK ]]; then
|
||||||
# ssh-agent running, start gpg-agent without ssh support
|
# ssh-agent running, start gpg-agent without ssh support
|
||||||
start_agent_nossh;
|
start_agent_nossh;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
if [[ -x `which nc` ]]; then
|
if [[ -x `which nc` ]]; then
|
||||||
alias nyan='nc -v nyancat.dakko.us 23' # nyan cat
|
alias nyan='nc -v miku.acm.uiuc.edu 23' # nyan cat
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue