2018-11-13 20:51:25 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-12-01 01:04:12 +03:00
|
|
|
trap 'unset GOGH_DRY_RUN; unset -f color; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
|
|
|
|
|
2018-11-13 20:51:25 +03:00
|
|
|
if [[ "${COLORTERM:-}" != "truecolor" ]] && [[ "${COLORTERM:-}" != "24bit" ]]; then
|
2018-12-01 01:04:12 +03:00
|
|
|
printf '%s\n' "TrueColor support is needed for this to function" \
|
|
|
|
"You can try to manually set COLORTERM to truecolor"
|
2018-11-13 20:51:25 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Print all themes without applying, this variable gets checked in apply-colors.sh
|
2018-12-01 01:04:12 +03:00
|
|
|
export GOGH_DRY_RUN=1
|
2018-11-13 20:51:25 +03:00
|
|
|
|
|
|
|
color () {
|
2018-12-01 01:04:12 +03:00
|
|
|
printf '%b\n' "${DEMO_COLOR_01} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 01 'tput setaf 0'" # black
|
|
|
|
printf '%b\n' "${DEMO_COLOR_02} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 02 'tput setaf 1'" # red
|
|
|
|
printf '%b\n' "${DEMO_COLOR_03} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 03 'tput setaf 2'" # green
|
|
|
|
printf '%b\n' "${DEMO_COLOR_04} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 04 'tput setaf 3'" # yellow
|
|
|
|
printf '%b\n' "${DEMO_COLOR_05} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 05 'tput setaf 4'" # blue
|
|
|
|
printf '%b\n' "${DEMO_COLOR_06} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 06 'tput setaf 5'" # pruple
|
|
|
|
printf '%b\n' "${DEMO_COLOR_07} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 07 'tput setaf 6'" # cyan
|
|
|
|
printf '%b\n\n' "${DEMO_COLOR_08} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 08 'tput setaf 7'" # white
|
|
|
|
printf '%b\n' "${DEMO_COLOR_09} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 09 'tput setaf 8'" # bold black
|
|
|
|
printf '%b\n' "${DEMO_COLOR_10} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 10 'tput setaf 9'" # bold red
|
|
|
|
printf '%b\n' "${DEMO_COLOR_11} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 11 'tput setaf 10'" # bold green
|
|
|
|
printf '%b\n' "${DEMO_COLOR_12} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 12 'tput setaf 11'" # bold yellow
|
|
|
|
printf '%b\n' "${DEMO_COLOR_13} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 13 'tput setaf 12'" # bold blue
|
|
|
|
printf '%b\n' "${DEMO_COLOR_14} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 14 'tput setaf 13'" # bold purple
|
|
|
|
printf '%b\n' "${DEMO_COLOR_15} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 15 'tput setaf 14'" # bold cyan
|
|
|
|
printf '%b\n\n' "${DEMO_COLOR_16} ███ *** AaBbCs --- ███ $(tput sgr0) ---> Color 16 'tput setaf 15'" # bold white
|
2018-11-13 20:51:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export -f color
|
|
|
|
|
|
|
|
declare -a THEMES=(
|
2020-09-17 20:39:35 +03:00
|
|
|
'omni.sh'
|
2018-11-29 23:48:25 +03:00
|
|
|
)
|
2018-11-13 20:51:25 +03:00
|
|
|
|
|
|
|
# Allow developer to change url to forked url for easier testing
|
2018-12-01 20:06:39 +03:00
|
|
|
# IMPORTANT: Make sure you export this variable if your main shell is not bash
|
2020-09-17 20:15:21 +03:00
|
|
|
BASE_URL=${BASE_URL:-"https://raw.githubusercontent.com/birobirobiro/Gogh/master/gogh.sh"}
|
2018-12-01 20:06:39 +03:00
|
|
|
PROGRESS_URL="https://raw.githubusercontent.com/phenonymous/shell-progressbar/1.0/progress.sh"
|
2018-11-13 20:51:25 +03:00
|
|
|
|
|
|
|
capitalize() {
|
2018-11-29 23:48:25 +03:00
|
|
|
local ARGUMENT=$1
|
|
|
|
local RES=""
|
|
|
|
local STR=""
|
|
|
|
local RES_NO_TRAIL_SPACE=""
|
2018-11-13 20:51:25 +03:00
|
|
|
|
2018-11-29 23:48:25 +03:00
|
|
|
for CHAR in $ARGUMENT
|
|
|
|
do
|
|
|
|
STR=$(echo "${CHAR:0:1}" | tr "[:lower:]" "[:upper:]")"${CHAR:1} "
|
|
|
|
RES="${RES}${STR}"
|
|
|
|
RES_NO_TRAIL_SPACE="$(echo -e "${RES}" | sed -e 's/[[:space:]]*$//')"
|
|
|
|
done
|
2018-11-13 20:51:25 +03:00
|
|
|
|
2018-11-29 23:48:25 +03:00
|
|
|
echo "${RES_NO_TRAIL_SPACE}"
|
2018-11-13 20:51:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
set_gogh() {
|
2018-11-29 23:48:25 +03:00
|
|
|
url="${BASE_URL}/themes/$1"
|
2018-11-13 20:51:25 +03:00
|
|
|
|
2018-11-29 23:48:25 +03:00
|
|
|
# Evaluate if Gogh was called from local source - i.e cloned repo
|
|
|
|
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
PARENT_PATH="$(dirname "${SCRIPT_PATH}")"
|
|
|
|
if [[ -e "${PARENT_PATH}/themes/$1" ]]; then
|
|
|
|
bash "${PARENT_PATH}/themes/$1"
|
|
|
|
else
|
|
|
|
if [[ "$(uname)" = "Darwin" ]]; then
|
2018-11-30 01:20:17 +03:00
|
|
|
bash -c "$(curl -so- "${url}")"
|
2018-11-13 20:51:25 +03:00
|
|
|
else
|
2018-11-30 01:20:17 +03:00
|
|
|
bash -c "$(wget -qO- "${url}")"
|
2018-11-13 20:51:25 +03:00
|
|
|
fi
|
2018-11-29 23:48:25 +03:00
|
|
|
fi
|
2018-11-13 20:51:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
remove_file_extension (){
|
2018-11-29 23:48:25 +03:00
|
|
|
echo "${1%.*}"
|
2018-11-13 20:51:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Fancy progress bar
|
2018-12-01 20:06:39 +03:00
|
|
|
# Note: We use eval here because we want the functions to be available in this script
|
2018-11-29 23:48:25 +03:00
|
|
|
if [[ "$(uname)" = "Darwin" ]]; then
|
2018-12-01 20:06:39 +03:00
|
|
|
eval "$(curl -so- ${PROGRESS_URL})" 2> /dev/null
|
2018-11-13 20:51:25 +03:00
|
|
|
else
|
2018-12-01 20:06:39 +03:00
|
|
|
eval "$(wget -qO- ${PROGRESS_URL})" 2> /dev/null
|
2018-11-13 20:51:25 +03:00
|
|
|
fi
|
|
|
|
|
2018-11-29 23:48:25 +03:00
|
|
|
declare color_dot_str
|
|
|
|
for c in {0..15}; do
|
|
|
|
color_dot_str+="$(tput setaf $c)•$(tput sgr0)"
|
|
|
|
[[ $c == 7 ]] && color_dot_str+=" "
|
|
|
|
done
|
|
|
|
|
2018-11-27 23:11:23 +03:00
|
|
|
command -v bar::start > /dev/null && bar::start
|
2018-11-13 20:51:25 +03:00
|
|
|
|
|
|
|
for THEME in "${THEMES[@]}"; do
|
|
|
|
LOOP=$((${LOOP:-(-1)}+1))
|
2018-11-27 23:11:23 +03:00
|
|
|
command -v bar::status_changed > /dev/null && bar::status_changed $LOOP ${#THEMES[@]}
|
2018-11-13 20:51:25 +03:00
|
|
|
|
|
|
|
FILENAME=$(remove_file_extension "${THEME}")
|
|
|
|
FILENAME_SPACE="${FILENAME//-/ }"
|
|
|
|
echo -e "\nTheme: $(capitalize "${FILENAME_SPACE}")"
|
2018-11-29 23:48:25 +03:00
|
|
|
echo "${color_dot_str}"
|
2018-11-13 20:51:25 +03:00
|
|
|
echo
|
|
|
|
set_gogh "${THEME}"
|
|
|
|
done
|
|
|
|
|
|
|
|
LOOP=$((${LOOP:-(-1)}+1))
|
2018-11-29 23:48:25 +03:00
|
|
|
command -v bar::status_changed > /dev/null && bar::status_changed $LOOP ${#THEMES[@]}
|
2018-11-13 20:51:25 +03:00
|
|
|
|
2018-11-29 23:48:25 +03:00
|
|
|
command -v bar::stop > /dev/null && bar::stop || :
|