Compare commits

..

2 Commits

Author SHA1 Message Date
Ceda EI 58aefa063b Add support for powerline_left and powerline_right 2021-09-22 13:25:35 +05:30
Ceda EI 7cb8857e5e Minor refactor 2021-09-22 13:07:31 +05:30
1 changed files with 20 additions and 14 deletions

34
wish.sh
View File

@ -1,10 +1,11 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090
# INTERNAL USE ONLY! Do not use this in plugins.
function wish_print_right_prompt() {
local idx=0
for i in ${WISH_RPL[@]}; do
echo "\e[$(($COLUMNS - $i + 1))G${WISH_RIGHT_PS1[$idx]}"
for i in "${WISH_RPL[@]}"; do
echo "\e[$((COLUMNS - i + 1))G${WISH_RIGHT_PS1[idx]}"
((idx++))
done
}
@ -22,10 +23,14 @@ function wish_init() {
# Source config files
for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
if [[ -f "$path/wish/wish.py" ]]; then
source <($path/wish/wish.py ${WISH_CONFIG_FILE[@]})
source <($path/wish/wish.py "${WISH_CONFIG_FILE[@]}")
break
fi
done
# Set defaults for core if not found
: "${WISH_POWERLINE_LEFT:=}"
: "${WISH_POWERLINE_RIGHT=}"
# Source all plugins
# If WISH_CONFIG_FILE is not set, then assume that the user hasn't updated
# to a config file yet. Set WISH_PLUGINS_SOURCE=WISH_PLUGINS.
@ -34,11 +39,12 @@ function wish_init() {
fi
local plugin
local path
for plugin in ${WISH_PLUGINS_SOURCE[@]}; do
for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
for plugin in "${WISH_PLUGINS_SOURCE[@]}"; do
if ! for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
source "$path/wish/plugins/$plugin.sh" &> /dev/null && break
done
[[ $? -ne 0 ]] && echo "Plugin $plugin not found." >&2
done; then
echo "Plugin $plugin not found." >&2
fi
done
# Source theme
@ -60,8 +66,8 @@ function wish_init() {
done
# Call plugins to set colors
for plugin in ${WISH_PLUGINS[@]} ${WISH_RIGHT_PLUGINS[@]}; do
eval wish_$(echo $plugin)_set_colors $prev
for plugin in "${WISH_PLUGINS[@]}" "${WISH_RIGHT_PLUGINS[@]}"; do
eval wish_${plugin}_set_colors $prev
done
}
@ -186,7 +192,7 @@ function wish_main() {
WISH_LPLINE=0
local i
# 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
if [[ $WISH_CURSOR_POSITION != "1" ]]; then
PS1="\n"
@ -204,12 +210,12 @@ function wish_main() {
local next_plugin=${WISH_PLUGINS[$(($i+1))]}
local fg_name="WISH_${plugin^^}_BG"
local bg_name="WISH_${next_plugin^^}_BG"
wish_append ${!bg_name} ${!fg_name}
wish_append ${!bg_name} ${!fg_name} "${WISH_POWERLINE_LEFT}"
fi
else
local plugin=${WISH_PLUGINS[$i]}
local fg_name="WISH_${plugin^^}_BG"
wish_append -1 ${!fg_name}
wish_append -1 ${!fg_name} "${WISH_POWERLINE_LEFT}"
fi
fi
fi
@ -222,13 +228,13 @@ function wish_main() {
if [[ $i == 0 ]]; then
local plugin=${WISH_RIGHT_PLUGINS[$i]}
local fg_name="WISH_${plugin^^}_BG"
wish_append -1 ${!fg_name}
wish_append -1 ${!fg_name} "${WISH_POWERLINE_RIGHT}"
elif wish_${WISH_RIGHT_PLUGINS[$(($i - 1))]}_start $prev; then
local plugin=${WISH_RIGHT_PLUGINS[$i]}
local prev_plugin=${WISH_RIGHT_PLUGINS[$(($i-1))]}
local fg_name="WISH_${plugin^^}_BG"
local bg_name="WISH_${prev_plugin^^}_BG"
wish_append ${!bg_name} ${!fg_name}
wish_append ${!bg_name} ${!fg_name} "${WISH_POWERLINE_RIGHT}"
fi
fi
fi