mirror of https://gitlab.com/ceda_ei/wish
Compare commits
No commits in common. "58aefa063b85eb6d38ebd4fb8f26ec007e5a689b" and "869a754ede67b10935164e2646a350ee6a66a66e" have entirely different histories.
58aefa063b
...
869a754ede
34
wish.sh
34
wish.sh
|
@ -1,11 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC1090
|
|
||||||
|
|
||||||
# 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
|
||||||
}
|
}
|
||||||
|
@ -23,14 +22,10 @@ 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
|
||||||
|
|
||||||
# Set defaults for core if not found
|
|
||||||
: "${WISH_POWERLINE_LEFT:=}"
|
|
||||||
: "${WISH_POWERLINE_RIGHT=}"
|
|
||||||
# Source all plugins
|
# Source all plugins
|
||||||
# If WISH_CONFIG_FILE is not set, then assume that the user hasn't updated
|
# 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.
|
# to a config file yet. Set WISH_PLUGINS_SOURCE=WISH_PLUGINS.
|
||||||
|
@ -39,12 +34,11 @@ 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
|
||||||
if ! for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
|
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; then
|
done
|
||||||
echo "Plugin $plugin not found." >&2
|
[[ $? -ne 0 ]] && echo "Plugin $plugin not found." >&2
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Source theme
|
# Source theme
|
||||||
|
@ -66,8 +60,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_${plugin}_set_colors $prev
|
eval wish_$(echo $plugin)_set_colors $prev
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +186,7 @@ function wish_main() {
|
||||||
WISH_LPLINE=0
|
WISH_LPLINE=0
|
||||||
local i
|
local i
|
||||||
# Set newline
|
# Set newline
|
||||||
if [[ $WISH_AUTO_NEWLINE != 0 ]]; then
|
if [[ $WISH_AUTONEWLINE != 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"
|
||||||
|
@ -210,12 +204,12 @@ function wish_main() {
|
||||||
local next_plugin=${WISH_PLUGINS[$(($i+1))]}
|
local next_plugin=${WISH_PLUGINS[$(($i+1))]}
|
||||||
local fg_name="WISH_${plugin^^}_BG"
|
local fg_name="WISH_${plugin^^}_BG"
|
||||||
local bg_name="WISH_${next_plugin^^}_BG"
|
local bg_name="WISH_${next_plugin^^}_BG"
|
||||||
wish_append ${!bg_name} ${!fg_name} "${WISH_POWERLINE_LEFT}"
|
wish_append ${!bg_name} ${!fg_name}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
local plugin=${WISH_PLUGINS[$i]}
|
local plugin=${WISH_PLUGINS[$i]}
|
||||||
local fg_name="WISH_${plugin^^}_BG"
|
local fg_name="WISH_${plugin^^}_BG"
|
||||||
wish_append -1 ${!fg_name} "${WISH_POWERLINE_LEFT}"
|
wish_append -1 ${!fg_name}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -228,13 +222,13 @@ function wish_main() {
|
||||||
if [[ $i == 0 ]]; then
|
if [[ $i == 0 ]]; then
|
||||||
local plugin=${WISH_RIGHT_PLUGINS[$i]}
|
local plugin=${WISH_RIGHT_PLUGINS[$i]}
|
||||||
local fg_name="WISH_${plugin^^}_BG"
|
local fg_name="WISH_${plugin^^}_BG"
|
||||||
wish_append -1 ${!fg_name} "${WISH_POWERLINE_RIGHT}"
|
wish_append -1 ${!fg_name}
|
||||||
elif wish_${WISH_RIGHT_PLUGINS[$(($i - 1))]}_start $prev; then
|
elif wish_${WISH_RIGHT_PLUGINS[$(($i - 1))]}_start $prev; then
|
||||||
local plugin=${WISH_RIGHT_PLUGINS[$i]}
|
local plugin=${WISH_RIGHT_PLUGINS[$i]}
|
||||||
local prev_plugin=${WISH_RIGHT_PLUGINS[$(($i-1))]}
|
local prev_plugin=${WISH_RIGHT_PLUGINS[$(($i-1))]}
|
||||||
local fg_name="WISH_${plugin^^}_BG"
|
local fg_name="WISH_${plugin^^}_BG"
|
||||||
local bg_name="WISH_${prev_plugin^^}_BG"
|
local bg_name="WISH_${prev_plugin^^}_BG"
|
||||||
wish_append ${!bg_name} ${!fg_name} "${WISH_POWERLINE_RIGHT}"
|
wish_append ${!bg_name} ${!fg_name}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue