Check that battery plugin is enabled before calling battery functions in demula theme

pull/227/head
Enrique Bautista 2013-08-31 16:23:38 +02:00
parent e0b2984e5c
commit f096b0fcc0
1 changed files with 10 additions and 2 deletions

View File

@ -82,6 +82,14 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
fi
}
# checks if the plugin is installed before calling battery_charge
safe_battery_charge() {
if [ -e "${BASH_IT}/plugins/enabled/battery.plugin.bash" ];
then
battery_charge
fi
}
# -------------------------------------------------------------- PROMPT OUTPUT
prompt() {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
@ -94,7 +102,7 @@ prompt() {
then
PS1="${TITLEBAR}
${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\
$(battery_charge)${RESTORE_CURSOR}\
$(safe_battery_charge)${RESTORE_CURSOR}\
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
@ -110,7 +118,7 @@ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
${LAST_COMMAND_FAILED}\
$(demula_vcprompt)\
$(is_vim_shell)\
$(battery_charge)
$(safe_battery_charge)
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
fi