mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Merge 8ead5d8d53 into 757fa3314d
This commit is contained in:
commit
2e632fe67e
2 changed files with 57 additions and 0 deletions
20
plugins/battery/battery.plugin.zsh
Normal file
20
plugins/battery/battery.plugin.zsh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
|
||||
function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
|
||||
function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
|
||||
function battery_pct_prompt() {
|
||||
b=$(battery_pct_remaining)
|
||||
if [ $b -gt 50 ] ; then
|
||||
color='green'
|
||||
elif [ $b -gt 20 ] ; then
|
||||
color='yellow'
|
||||
else
|
||||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
|
||||
}
|
||||
else
|
||||
error_msg='no battery'
|
||||
function battery_pct_remaining() { echo $error_msg }
|
||||
function battery_time_remaining() { echo $error_msg }
|
||||
function battery_pct_prompt() { echo '' }
|
||||
fi
|
||||
37
plugins/rbenv/rbenv.plugin.zsh
Normal file
37
plugins/rbenv/rbenv.plugin.zsh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
rbenvdir=$HOME/.rbenv/bin
|
||||
if [ -d $rbenvdir ] ; then
|
||||
export PATH=$rbenvdir:$PATH
|
||||
eval "$(rbenv init -)"
|
||||
|
||||
alias rubies="rbenv versions"
|
||||
alias gemsets="rbenv gemset list"
|
||||
|
||||
function current_ruby() {
|
||||
echo "$(rbenv version | cut -f1 -d ' ')"
|
||||
}
|
||||
|
||||
function current_gemset() {
|
||||
echo "$(rbenv gemset active 2&>/dev/null | grep -v 'no active gemsets')"
|
||||
}
|
||||
|
||||
function gems {
|
||||
local rbenv_path=$(rbenv prefix)
|
||||
gem list $@ | sed \
|
||||
-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \
|
||||
-Ee "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
|
||||
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
|
||||
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
|
||||
}
|
||||
|
||||
function rbenv_prompt_info() {
|
||||
if [[ -n $(current_gemset) ]] ; then
|
||||
echo "$(current_ruby)@$(current_gemset)"
|
||||
else
|
||||
echo "$(current_ruby)"
|
||||
fi
|
||||
}
|
||||
else
|
||||
alias rubies='ruby -v'
|
||||
function gemsets() { echo 'not supported' }
|
||||
function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" }
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue