Minor refactor

This commit is contained in:
Ceda EI 2021-09-22 13:07:31 +05:30
parent 869a754ede
commit 7cb8857e5e
1 changed files with 11 additions and 10 deletions

21
wish.sh
View File

@ -3,8 +3,8 @@
# INTERNAL USE ONLY! Do not use this in plugins. # INTERNAL USE ONLY! Do not use this in plugins.
function wish_print_right_prompt() { function wish_print_right_prompt() {
local idx=0 local idx=0
for i in ${WISH_RPL[@]}; do for i in "${WISH_RPL[@]}"; do
echo "\e[$(($COLUMNS - $i + 1))G${WISH_RIGHT_PS1[$idx]}" echo "\e[$((COLUMNS - i + 1))G${WISH_RIGHT_PS1[idx]}"
((idx++)) ((idx++))
done done
} }
@ -22,7 +22,7 @@ function wish_init() {
# Source config files # Source config files
for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
if [[ -f "$path/wish/wish.py" ]]; then if [[ -f "$path/wish/wish.py" ]]; then
source <($path/wish/wish.py ${WISH_CONFIG_FILE[@]}) source <($path/wish/wish.py "${WISH_CONFIG_FILE[@]}")
break break
fi fi
done done
@ -34,11 +34,12 @@ function wish_init() {
fi fi
local plugin local plugin
local path local path
for plugin in ${WISH_PLUGINS_SOURCE[@]}; do for plugin in "${WISH_PLUGINS_SOURCE[@]}"; do
for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do if ! for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
source "$path/wish/plugins/$plugin.sh" &> /dev/null && break source "$path/wish/plugins/$plugin.sh" &> /dev/null && break
done done; then
[[ $? -ne 0 ]] && echo "Plugin $plugin not found." >&2 echo "Plugin $plugin not found." >&2
fi
done done
# Source theme # Source theme
@ -60,8 +61,8 @@ function wish_init() {
done done
# Call plugins to set colors # Call plugins to set colors
for plugin in ${WISH_PLUGINS[@]} ${WISH_RIGHT_PLUGINS[@]}; do for plugin in "${WISH_PLUGINS[@]}" "${WISH_RIGHT_PLUGINS[@]}"; do
eval wish_$(echo $plugin)_set_colors $prev eval wish_${plugin}_set_colors $prev
done done
} }
@ -186,7 +187,7 @@ function wish_main() {
WISH_LPLINE=0 WISH_LPLINE=0
local i local i
# Set newline # Set newline
if [[ $WISH_AUTONEWLINE != 0 ]]; then if [[ $WISH_AUTO_NEWLINE != 0 ]]; then
echo -ne "\033[6n" ; read -s -d ';'; read -s -d R WISH_CURSOR_POSITION echo -ne "\033[6n" ; read -s -d ';'; read -s -d R WISH_CURSOR_POSITION
if [[ $WISH_CURSOR_POSITION != "1" ]]; then if [[ $WISH_CURSOR_POSITION != "1" ]]; then
PS1="\n" PS1="\n"