From 3fac1c7ea5b3ce4d0a270f8bea0e516278bc7473 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 29 May 2017 17:29:06 +0200 Subject: [PATCH] Fix checks for battery plugin These now check for the presence of the required function instead of checking for the battery file in the enabled directory. --- themes/base.theme.bash | 4 +++- themes/brainy/brainy.theme.bash | 2 +- themes/demula/demula.theme.bash | 11 +++++------ themes/rana/rana.theme.bash | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 84928acd..89c01e3b 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -474,13 +474,15 @@ function battery_char { fi } -if [ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ]; then +if ! command_exists battery_charge ; then # if user has installed battery plugin, skip this... function battery_charge (){ # no op echo -n } +fi +if ! command_exists battery_char ; then function battery_char (){ # no op echo -n diff --git a/themes/brainy/brainy.theme.bash b/themes/brainy/brainy.theme.bash index e840c004..d689332e 100644 --- a/themes/brainy/brainy.theme.bash +++ b/themes/brainy/brainy.theme.bash @@ -152,7 +152,7 @@ ___brainy_prompt_clock() { } ___brainy_prompt_battery() { - [ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ] || + ! command_exists battery_percentage || [ "${THEME_SHOW_BATTERY}" != "true" ] && return info=$(battery_percentage) color=$bold_green diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index ed03a708..e698def5 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash # Theme inspired on: # - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ @@ -10,7 +10,7 @@ # Screenshot: http://goo.gl/VCmX5 # by Jesus de Mula -# For the real Monokai colors you should add these to your .XDefaults or +# For the real Monokai colors you should add these to your .XDefaults or # terminal configuration: #! ----------------------------------------------------------- TERMINAL COLORS #! monokai - http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/ @@ -68,7 +68,7 @@ mitsuhikos_lastcommandfailed() { if [ $code != 0 ]; then echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\ -$code ${D_DEFAULT_COLOR}" +$code ${D_DEFAULT_COLOR}" fi } @@ -78,13 +78,13 @@ demula_vcprompt() { then local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" - $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" + $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" fi } # checks if the plugin is installed before calling battery_charge safe_battery_charge() { - if [ -e "${BASH_IT}/plugins/enabled/battery.plugin.bash" ]; + if command_exists battery_charge ; then battery_charge fi @@ -127,4 +127,3 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" # Runs prompt (this bypasses bash_it $PROMPT setting) safe_append_prompt_command prompt - diff --git a/themes/rana/rana.theme.bash b/themes/rana/rana.theme.bash index c1122429..0aed8348 100644 --- a/themes/rana/rana.theme.bash +++ b/themes/rana/rana.theme.bash @@ -117,7 +117,7 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" # checks if the plugin is installed before calling battery_charge safe_battery_charge() { - if [ -e "${BASH_IT}/plugins/enabled/battery.plugin.bash" ]; + if command_exists battery_charge ; then battery_charge fi