From e0b2984e5c9a0d708db4d1603b822a2bb783674b Mon Sep 17 00:00:00 2001 From: Enrique Bautista Date: Fri, 30 Aug 2013 18:18:08 +0200 Subject: [PATCH 1/2] Fixed display of last failed command in demula theme --- themes/demula/demula.theme.bash | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index 1f13f1e7..8cfdb784 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -84,6 +84,7 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" # -------------------------------------------------------------- PROMPT OUTPUT prompt() { + local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\033[s' local RESTORE_CURSOR='\033[u' local MOVE_CURSOR_RIGHTMOST='\033[500C' @@ -97,7 +98,7 @@ $(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}\ -$(mitsuhikos_lastcommandfailed)\ +${LAST_COMMAND_FAILED}\ $(demula_vcprompt)\ $(is_vim_shell) ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" @@ -106,7 +107,7 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ -$(mitsuhikos_lastcommandfailed)\ +${LAST_COMMAND_FAILED}\ $(demula_vcprompt)\ $(is_vim_shell)\ $(battery_charge) From f096b0fcc088bda3862f2fcff086329328254922 Mon Sep 17 00:00:00 2001 From: Enrique Bautista Date: Sat, 31 Aug 2013 16:23:38 +0200 Subject: [PATCH 2/2] Check that battery plugin is enabled before calling battery functions in demula theme --- themes/demula/demula.theme.bash | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index 8cfdb784..15faeded 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -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