lib/preview: refactor into a function
This allows future use like `bash-it preview`. Alsö, allows to use `$BASH_PREVIEW` to specify a particular theme to preview instead of just doing all of them.pull/2017/head
parent
4dbe92e38d
commit
d6555f369a
|
|
@ -85,6 +85,7 @@ lib/colors.bash
|
||||||
lib/helpers.bash
|
lib/helpers.bash
|
||||||
lib/log.bash
|
lib/log.bash
|
||||||
lib/preexec.bash
|
lib/preexec.bash
|
||||||
|
lib/preview.bash
|
||||||
lib/search.bash
|
lib/search.bash
|
||||||
lib/utilities.bash
|
lib/utilities.bash
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,30 @@
|
||||||
if [[ "${BASH_PREVIEW:-}" ]];
|
# shellcheck shell=bash
|
||||||
then
|
#
|
||||||
unset BASH_PREVIEW #Prevent infinite looping
|
# Displays the prompt from each _Bash It_ theme.
|
||||||
echo "
|
|
||||||
|
|
||||||
Previewing Bash-it Themes
|
function _bash-it-preview() {
|
||||||
|
local BASH_IT_THEME BASH_IT_LOG_LEVEL
|
||||||
|
local themes theme
|
||||||
|
|
||||||
"
|
printf '\n\n\t%s\n\n' "Previewing Bash-it Themes"
|
||||||
|
|
||||||
THEMES="$BASH_IT/themes/*/*.theme.bash"
|
if [[ -n "${1:-}" && -s "${BASH_IT?}/themes/${1}/${1}.theme.bash" ]]; then
|
||||||
for theme in $THEMES
|
themes=("${1}")
|
||||||
do
|
else
|
||||||
BASH_IT_THEME=${theme%.theme.bash}
|
themes=("${BASH_IT?}/themes"/*/*.theme.bash)
|
||||||
BASH_IT_THEME=${BASH_IT_THEME##*/}
|
fi
|
||||||
echo "
|
|
||||||
$BASH_IT_THEME"
|
# shellcheck disable=SC2034
|
||||||
echo "" | bash --init-file "${BASH_IT}/bash_it.sh" -i
|
for theme in "${themes[@]}"; do
|
||||||
done
|
BASH_IT_THEME="${theme%.theme.bash}"
|
||||||
|
BASH_IT_THEME="${BASH_IT_THEME##*/}"
|
||||||
|
BASH_IT_LOG_LEVEL=0
|
||||||
|
|
||||||
|
bash --init-file "${BASH_IT_BASHRC:-${BASH_IT?}/bash_it.sh}" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"'
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -n "${BASH_PREVIEW:-}" ]]; then
|
||||||
|
_bash-it-preview "${BASH_PREVIEW}" "$@"
|
||||||
|
unset BASH_PREVIEW #Prevent infinite looping
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue