1
0
mirror of https://gitlab.com/ceda_ei/wish synced 2025-11-03 15:50:08 +01:00

1 Commits

Author SHA1 Message Date
dfd0baaf6a Replace escape codes with tput 2019-03-02 12:25:03 +05:30
7 changed files with 13 additions and 56 deletions

View File

@@ -1,16 +1,10 @@
#!/usr/bin/env bash
if hash git; then
git clone https://gitlab.com/ceda_ei/wish.git $HOME/.config/wish.git
else
curl https://gitlab.com/ceda_ei/wish/-/archive/master/wish-master.tar -o /tmp/wish.tar
mkdir $HOME/.config 2> /dev/null
cd /tmp/
tar xf wish.tar
mv wish-master/ wish/
mv wish/ $HOME/.config/
fi
curl https://gitlab.com/ceda_ei/wish/-/archive/master/wish-master.tar -o /tmp/wish.tar
cd /tmp/
tar xf wish.tar
mv wish-master/ wish/
mv wish/ $HOME/.config/
cat >> ~/.bashrc <<EOF
# Wish
@@ -19,3 +13,4 @@ WISH_PLUGINS=(exit_code_smiley bg_jobs date path newline vcs)
WISH_THEME=plain
source ~/.config/wish/wish.sh
EOF

View File

@@ -11,14 +11,11 @@ function wish_exit_code_smiley_set_colors() {
WISH_EXIT_CODE_SMILEY_BG=${WISH_EXIT_CODE_SMILEY_BG:-$WISH_DEFAULT_BG}
WISH_EXIT_CODE_SMILEY_PASS=${WISH_EXIT_CODE_SMILEY_PASS:- :) }
WISH_EXIT_CODE_SMILEY_FAIL=${WISH_EXIT_CODE_SMILEY_FAIL:- :( }
WISH_EXIT_CODE_SMILEY_HIDE_ON_PASS=${WISH_EXIT_CODE_SMILEY_HIDE_ON_PASS:-0}
}
function wish_exit_code_smiley_main() {
if [[ $1 == 0 ]]; then
if [[ $WISH_EXIT_CODE_SMILEY_HIDE_ON_PASS == 0 ]]; then
wish_append $WISH_EXIT_CODE_SMILEY_BG $WISH_EXIT_CODE_SMILEY_FG "$WISH_EXIT_CODE_SMILEY_PASS"
fi
else
wish_append $WISH_EXIT_CODE_SMILEY_BG $WISH_EXIT_CODE_SMILEY_FG "$WISH_EXIT_CODE_SMILEY_FAIL"
fi

View File

@@ -15,7 +15,7 @@ function wish_vcs_set_colors() {
}
function wish_vcs_main() {
local op=$(git diff --numstat 2> /dev/null || echo -1)
local op=$(git diff --numstat HEAD 2> /dev/null || echo -1)
if [[ $op != "-1" ]]; then
local git
git="$git $WISH_VCS_GIT_SYMBOL "

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
local i
local gradient=(226 118 37 66 60 237 233)
local fg_gradient=(16 16 16 16 16 15 15)
local j=0
for i in ${WISH_PLUGINS[@]}; do
[[ $i == "newline" ]] && j=0 && continue
eval WISH_$(echo $i | tr '[:lower:]' '[:upper:]')_BG=${gradient[$j]}
eval WISH_$(echo $i | tr '[:lower:]' '[:upper:]')_FG=${fg_gradient[$j]}
((j++))
if [[ $j -eq ${#gradient[@]} ]]; then
j=0
fi
done

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
WISH_POWERLINE=0
local i
local gradient=(e7c547 c0e551 82e35a 62e177 6bdfb3 73d4dd 7aa6da)
local j=0
for i in ${WISH_PLUGINS[@]}; do
[[ $i == "newline" ]] && j=0 && continue
eval WISH_$(echo $i | tr '[:lower:]' '[:upper:]')_BG=-1
eval WISH_$(echo $i | tr '[:lower:]' '[:upper:]')_FG=${gradient[$j]}
((j++))
if [[ $j -eq ${#gradient[@]} ]]; then
j=0
fi
done

View File

@@ -3,6 +3,7 @@
local i
local gradient=(ffff5f 7ad767 66b097 5e7388 534d61 3a3338 121212)
local fg_gradient=(000000 000000 000000 000000 000000 ffffff ffffff)
# local gradient=(888888 999999)
local j=0
for i in ${WISH_PLUGINS[@]}; do
[[ $i == "newline" ]] && j=0 && continue

14
wish.sh
View File

@@ -31,7 +31,7 @@ function wish_append() {
local fg_code=$2
local text=$3
if [[ $fg_code == -1 ]]; then
local fg="\[\033[0;5;0m\]"
local fg=$(tput sgr0)
else
if [[ ${#fg_code} -eq 6 ]]; then
local color=($(echo $fg_code | grep -o .))
@@ -40,11 +40,11 @@ function wish_append() {
local b=$(( 16#${color[4]}${color[5]} ))
local fg="\[\033[38;2;$r;$g;${b}m\]"
else
local fg="\[\033[38;5;${fg_code}m\]"
local fg=$(tput setaf $fg_code)
fi
fi
if [[ $bg_code == -1 ]]; then
local bg="\[\033[0;5;0m\]"
local bg=$(tput sgr0)
else
if [[ ${#bg_code} -eq 6 ]]; then
local color=($(echo $bg_code | grep -o .))
@@ -53,7 +53,7 @@ function wish_append() {
local b=$(( 16#${color[4]}${color[5]} ))
local bg="\[\033[48;2;$r;$g;${b}m\]"
else
local bg="\[\033[48;5;${bg_code}m\]"
local bg=$(tput setab $bg_code)
fi
fi
@@ -69,12 +69,6 @@ function wish_main() {
local prev=$?
PS1=""
local i
if [[ $WISH_AUTONEWLINE != 0 ]]; then
echo -ne "\033[6n" ; read -s -d ';'; read -s -d R WISH_CURSOR_POSITION
if [[ $WISH_CURSOR_POSITION != "1" ]]; then
PS1="\n"
fi
fi
for i in $(seq 0 $((${#WISH_PLUGINS[@]} - 1))); do
wish_${WISH_PLUGINS[i]}_main $prev
if [[ -v WISH_POWERLINE ]] && [[ $WISH_POWERLINE != 0 ]]; then