Skip to content

Commit 8ef853c

Browse files
committed
lib/battery: rename plugin/battery
This plugin *only* provides utility functions, so it has zero cost to just being enabled. This allows us to eliminate assumptions from `lib/theme` and several themes.
1 parent 4dbe92e commit 8ef853c

File tree

6 files changed

+5
-38
lines changed

6 files changed

+5
-38
lines changed

clean_files.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ completion/available/vuejs.completion.bash
8181
completion/available/wpscan.completion.bash
8282

8383
# libraries
84+
lib/battery.bash
8485
lib/colors.bash
8586
lib/helpers.bash
8687
lib/log.bash
@@ -94,7 +95,6 @@ plugins/available/alias-completion.plugin.bash
9495
plugins/available/autojump.plugin.bash
9596
plugins/available/base.plugin.bash
9697
plugins/available/basher.plugin.bash
97-
plugins/available/battery.plugin.bash
9898
plugins/available/blesh.plugin.bash
9999
plugins/available/cmd-returned-notify.plugin.bash
100100
plugins/available/colors.plugin.bash
File renamed without changes.
File renamed without changes.

themes/base.theme.bash

-17
Original file line numberDiff line numberDiff line change
@@ -558,23 +558,6 @@ function battery_char {
558558
fi
559559
}
560560

561-
if ! _command_exists battery_charge; then
562-
# if user has installed battery plugin, skip this...
563-
function battery_charge() {
564-
# no op
565-
echo -n
566-
}
567-
fi
568-
569-
# The battery_char function depends on the presence of the battery_percentage function.
570-
# If battery_percentage is not defined, then define battery_char as a no-op.
571-
if ! _command_exists battery_percentage; then
572-
function battery_char() {
573-
# no op
574-
echo -n
575-
}
576-
fi
577-
578561
function aws_profile {
579562
if [[ $AWS_DEFAULT_PROFILE ]]; then
580563
echo -e "${AWS_DEFAULT_PROFILE}"

themes/demula/demula.theme.bash

+2-10
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
8282
fi
8383
}
8484

85-
# checks if the plugin is installed before calling battery_charge
86-
safe_battery_charge() {
87-
if _command_exists battery_charge ;
88-
then
89-
battery_charge
90-
fi
91-
}
92-
9385
# -------------------------------------------------------------- PROMPT OUTPUT
9486
prompt() {
9587
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
@@ -101,7 +93,7 @@ prompt() {
10193
if [[ "$OSTYPE" = 'linux'* ]]
10294
then
10395
PS1="${TITLEBAR}${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}
104-
$(safe_battery_charge)${RESTORE_CURSOR}\
96+
$(battery_charge)${RESTORE_CURSOR}\
10597
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
10698
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
10799
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
@@ -117,7 +109,7 @@ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
117109
${LAST_COMMAND_FAILED}\
118110
$(demula_vcprompt)\
119111
$(is_vim_shell)\
120-
$(safe_battery_charge)
112+
$(battery_charge)
121113
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
122114
fi
123115

themes/rana/rana.theme.bash

+2-10
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
115115
fi
116116
}
117117

118-
# checks if the plugin is installed before calling battery_charge
119-
safe_battery_charge() {
120-
if _command_exists battery_charge ;
121-
then
122-
battery_charge
123-
fi
124-
}
125-
126118
prompt_git() {
127119
local s='';
128120
local branchName='';
@@ -185,7 +177,7 @@ prompt() {
185177
then
186178
PS1="${TITLEBAR}
187179
${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\
188-
$(safe_battery_charge)${RESTORE_CURSOR}\
180+
$(battery_charge)${RESTORE_CURSOR}\
189181
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
190182
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
191183
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
@@ -203,7 +195,7 @@ $(prompt_git "$D_INTERMEDIATE_COLOR on $D_GIT_COLOR")\
203195
${LAST_COMMAND_FAILED}\
204196
$(demula_vcprompt)\
205197
$(is_vim_shell)\
206-
$(safe_battery_charge)
198+
$(battery_charge)
207199
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
208200
fi
209201

0 commit comments

Comments
 (0)