Ascii: More cleanup

This commit is contained in:
Dylan Araps 2016-11-13 20:58:59 +11:00
parent 234ce87aab
commit 0a9aa93aad
1 changed files with 54 additions and 49 deletions

103
neofetch
View File

@ -1852,18 +1852,6 @@ get_image_backend() {
esac esac
} }
get_image_program() {
if [[ -n "$ITERM_PROFILE" ]]; then
image_program="iterm2"
elif [[ "$(tycat 2>/dev/null)" ]]; then
image_program="tycat"
else
image_program="w3m"
fi
}
get_ascii() { get_ascii() {
if [[ ! -f "$ascii" || "$ascii" == "distro" ]]; then if [[ ! -f "$ascii" || "$ascii" == "distro" ]]; then
# Error message # Error message
@ -1935,6 +1923,18 @@ get_ascii() {
export LC_ALL=C export LC_ALL=C
} }
get_image_program() {
if [[ -n "$ITERM_PROFILE" ]]; then
image_program="iterm2"
elif [[ "$(tycat 2>/dev/null)" ]]; then
image_program="tycat"
else
image_program="w3m"
fi
}
get_w3m_img_path() { get_w3m_img_path() {
if [[ -x "$w3m_img_path" ]]; then if [[ -x "$w3m_img_path" ]]; then
return return
@ -2370,6 +2370,43 @@ get_underline() {
fi fi
} }
bold() {
case "$ascii_bold" in
"on") ascii_bold="\033[1m" ;;
"off") ascii_bold="" ;;
esac
case "$bold" in
"on") bold="\033[1m" ;;
"off") bold="" ;;
esac
}
get_line_break() {
line_break=" "
# Calculate info height
info_height="$((info_height+=1))"
}
trim() {
# When a string is passed to 'echo' all trailing and leading
# whitespace is removed and inside the string multiple spaces are
# condensed into single spaces.
#
# The 'set -f/+f' is here so that 'echo' doesn't cause any expansion
# of special characters.
#
# The whitespace trim doesn't work with multiline strings so we use
# '${1//[[:space:]]/ }' to remove newlines beofre we trim the whitespace.
set -f
builtin echo -E ${1//[[:space:]]/ }
set +f
}
# COLORS
get_distro_colors() { get_distro_colors() {
# This function sets the text colors according # This function sets the text colors according
# to your OS/Distro's logo colors. # to your OS/Distro's logo colors.
@ -2514,6 +2551,7 @@ get_distro_colors() {
} }
set_colors() { set_colors() {
# Ascii colors
c1="$(color "$1")${ascii_bold}" c1="$(color "$1")${ascii_bold}"
c2="$(color "$2")${ascii_bold}" c2="$(color "$2")${ascii_bold}"
c3="$(color "$3")${ascii_bold}" c3="$(color "$3")${ascii_bold}"
@ -2521,6 +2559,7 @@ set_colors() {
c5="$(color "$5")${ascii_bold}" c5="$(color "$5")${ascii_bold}"
c6="$(color "$6")${ascii_bold}" c6="$(color "$6")${ascii_bold}"
# Text colors
if [[ "${colors[0]}" == "distro" ]]; then if [[ "${colors[0]}" == "distro" ]]; then
title_color="$(color "$1")" title_color="$(color "$1")"
at_color="$reset" at_color="$reset"
@ -2541,6 +2580,7 @@ set_colors() {
info_color="$(color "${colors[5]}")" info_color="$(color "${colors[5]}")"
fi fi
# Progress Bar colors
if [[ "$progress_color_elapsed" == "distro" ]]; then if [[ "$progress_color_elapsed" == "distro" ]]; then
progress_color_elapsed="$(color fg)" progress_color_elapsed="$(color fg)"
else else
@ -2548,8 +2588,8 @@ set_colors() {
fi fi
case "$progress_color_total $1" in case "$progress_color_total $1" in
distro\ [736]) progress_color_total="$c2" ;; "distro "[736]) progress_color_total="$c2" ;;
distro\ [0-9]) progress_color_total="$c1" ;; "distro "[0-9]) progress_color_total="$c1" ;;
*) progress_color_total="$(color "$progress_color_total")" ;; *) progress_color_total="$(color "$progress_color_total")" ;;
esac esac
} }
@ -2562,41 +2602,6 @@ color() {
esac esac
} }
bold() {
case "$ascii_bold" in
"on") ascii_bold="\033[1m" ;;
"off") ascii_bold="" ;;
esac
case "$bold" in
"on") bold="\033[1m" ;;
"off") bold="" ;;
esac
}
get_line_break() {
line_break=" "
# Calculate info height
info_height="$((info_height+=1))"
}
trim() {
# When a string is passed to 'echo' all trailing and leading
# whitespace is removed and inside the string multiple spaces are
# condensed into single spaces.
#
# The 'set -f/+f' is here so that 'echo' doesn't cause any expansion
# of special characters.
#
# The whitespace trim doesn't work with multiline strings so we use
# '${1//[[:space:]]/ }' to remove newlines beofre we trim the whitespace.
set -f
builtin echo -E ${1//[[:space:]]/ }
set +f
}
# OTHER # OTHER
err() { err() {