From 3ffefaef7436762b4c0978e702d1d3ad74908f31 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sat, 16 Feb 2019 11:04:56 +0530 Subject: [PATCH] Add powerline support --- wish.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/wish.sh b/wish.sh index f177a71..b83eb71 100644 --- a/wish.sh +++ b/wish.sh @@ -27,6 +27,31 @@ function wish_main() { local i for i in $(seq 0 $((${#WISH_PLUGINS[@]} - 1))); do wish_${WISH_PLUGINS[i]}_main $prev + if [[ -v WISH_POWERLINE ]] && [[ $WISH_POWERLINE != 0 ]]; then + if wish_${WISH_PLUGINS[$i]}_end $prev; then + if [[ $i -lt $((${#WISH_PLUGINS[@]} - 1)) ]]; then + if wish_${WISH_PLUGINS[$(($i + 1))]}_start $prev; then + local plugin=${WISH_PLUGINS[$i]} + local next_plugin=${WISH_PLUGINS[$(($i+1))]} + local fg=$(eval echo \$WISH_$(echo $plugin | + tr '[:lower:]' '[:upper:]')_BG) + local bg=$(eval echo \$WISH_$(echo $next_plugin | + tr '[:lower:]' '[:upper:]')_BG) + PS1="$PS1\[\033[38;5;${fg}m\]\[\033[48;5;${bg}m\]" + fi + else + local plugin=${WISH_PLUGINS[$i]} + local fg=$(eval echo \$WISH_$(echo $plugin | + tr '[:lower:]' '[:upper:]')_BG) + PS1="$PS1\[\033[0;5;0m\]" + PS1="$PS1\[\033[38;5;${fg}m\]" + fi + fi + fi + + if [[ $i -eq $((${#WISH_PLUGINS[@]} - 1)) ]]; then + PS1="$PS1\[\033[0;5;0m\]" + fi done }