mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
Merge pull request #289 from akinomyoga/fix-kitsune-and-battery
Fix kitsune.theme and battery.plugin
This commit is contained in:
@ -55,14 +55,15 @@ ac_adapter_disconnected(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## @fn battery_percentage
|
||||||
|
## @about 'displays battery charge as a percentage of full (100%)'
|
||||||
|
## @group 'battery'
|
||||||
battery_percentage(){
|
battery_percentage(){
|
||||||
about 'displays battery charge as a percentage of full (100%)'
|
|
||||||
group 'battery'
|
|
||||||
|
|
||||||
if command_exists upower;
|
if command_exists upower;
|
||||||
then
|
then
|
||||||
local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p')
|
local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p')
|
||||||
echo ${UPOWER_OUTPUT: : -1}
|
[[ $UPOWER_OUTPUT ]] &&
|
||||||
|
echo "${UPOWER_OUTPUT::-1}"
|
||||||
elif command_exists acpi;
|
elif command_exists acpi;
|
||||||
then
|
then
|
||||||
local ACPI_OUTPUT=$(acpi -b)
|
local ACPI_OUTPUT=$(acpi -b)
|
||||||
@ -128,10 +129,10 @@ battery_percentage(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## @fn battery_charge
|
||||||
|
## @about 'graphical display of your battery charge'
|
||||||
|
## @group 'battery'
|
||||||
battery_charge(){
|
battery_charge(){
|
||||||
about 'graphical display of your battery charge'
|
|
||||||
group 'battery'
|
|
||||||
|
|
||||||
# Full char
|
# Full char
|
||||||
local F_C='▸'
|
local F_C='▸'
|
||||||
# Depleted char
|
# Depleted char
|
||||||
|
@ -4,28 +4,32 @@
|
|||||||
#
|
#
|
||||||
# prompt theming
|
# prompt theming
|
||||||
|
|
||||||
# added TITLEBAR for updating the tab and window titles with the pwd
|
_omb_module_require plugin:battery
|
||||||
case $TERM in
|
|
||||||
xterm*)
|
|
||||||
TITLEBAR=$(printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}")
|
|
||||||
;;
|
|
||||||
screen)
|
|
||||||
TITLEBAR=$(printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}")
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
TITLEBAR=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if [ "$?" == "0" ]
|
|
||||||
then
|
|
||||||
SC="${green}^_^";
|
|
||||||
else
|
|
||||||
SC="${red}T_T";
|
|
||||||
fi
|
|
||||||
BC=`battery_percentage`
|
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
#PS1="${TITLEBAR}[\u@\h \W $(scm_prompt_info)]\$ "
|
local status=$?
|
||||||
PS1="\n${cyan}┌─${bold_white}[\u@\h]${cyan}─${bold_yellow}(\w)$(scm_prompt_info)\n${cyan}└─${bold_green}[\A]-${green}($BC%)${bold_cyan}-[${green}${bold_green}\$${bold_cyan}]${green} "
|
|
||||||
|
# added TITLEBAR for updating the tab and window titles with the pwd
|
||||||
|
local TITLEBAR
|
||||||
|
case $TERM in
|
||||||
|
xterm* | screen)
|
||||||
|
TITLEBAR=$'\1\e]0;'$USER@${HOSTNAME%%.*}:${PWD/#$HOME/~}$'\e\\\2' ;;
|
||||||
|
*)
|
||||||
|
TITLEBAR= ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local SC
|
||||||
|
if ((status == 0)); then
|
||||||
|
SC="$cyan-$bold_green(${green}^_^$bold_green)";
|
||||||
|
else
|
||||||
|
SC="$cyan-$bold_green(${red}T_T$bold_green)";
|
||||||
|
fi
|
||||||
|
|
||||||
|
local BC=$(battery_percentage)
|
||||||
|
[[ $BC == no && $BC == -1 ]] && BC=
|
||||||
|
BC=${BC:+${cyan}-${green}($BC%)}
|
||||||
|
|
||||||
|
PS1=$TITLEBAR"\n${cyan}┌─${bold_white}[\u@\h]${cyan}─${bold_yellow}(\w)$(scm_prompt_info)\n${cyan}└─${bold_green}[\A]$SC$BC${cyan}-${bold_cyan}[${green}${bold_green}\$${bold_cyan}]${green} "
|
||||||
}
|
}
|
||||||
|
|
||||||
# scm theming
|
# scm theming
|
||||||
|
Reference in New Issue
Block a user