Check in /usr/share/fetch/ascii/ before falling back to script location

This commit is contained in:
Dylan 2016-01-29 09:45:35 +11:00
parent 9bde0eb888
commit 55fcf79796
1 changed files with 28 additions and 15 deletions

43
fetch
View File

@ -1338,23 +1338,35 @@ getascii () {
esac esac
if [ "$ascii" == "distro" ]; then if [ "$ascii" == "distro" ]; then
# Get distro ascii file # Lowercase the distro name
ascii=${ascii_distro,,} ascii=${ascii_distro,,}
# Use $0 to get the script's physical path. # Check /usr/share/fetch for ascii before
cd "${0%/*}" # looking in the script's directory.
ascii_dir=${0##*/} if [ -f "/usr/share/fetch/ascii/distro/${ascii/ *}" ]; then
ascii="/usr/share/fetch/ascii/distro/${ascii/ *}"
else
# Use $0 to get the script's physical path.
cd "${0%/*}"
ascii_dir=${0##*/}
# Iterate down a (possible) chain of symlinks. # Iterate down a (possible) chain of symlinks.
while [ -L "$ascii_dir" ]; do while [ -L "$ascii_dir" ]; do
ascii_dir="$(readlink $ascii_dir)" ascii_dir="$(readlink $ascii_dir)"
cd "${ascii_dir%/*}" cd "${ascii_dir%/*}"
ascii_dir="${ascii_dir##*/}" ascii_dir="${ascii_dir##*/}"
done done
# Final directory # Final directory
ascii_dir="$(pwd -P)" ascii_dir="$(pwd -P)"
ascii="$ascii_dir/ascii/distro/${ascii/ *}"
if [ -f "$ascii_dir/ascii/distro/${ascii/ *}" ]; then
ascii="$ascii_dir/ascii/distro/${ascii/ *}"
else
padding="\033[0C"
return
fi
fi
# Overwrite distro colors if '$ascii_color` doesn't # Overwrite distro colors if '$ascii_color` doesn't
# equal 'distro'. # equal 'distro'.
@ -1378,9 +1390,10 @@ getascii () {
print="${ascii_color}$(<"$ascii")" print="${ascii_color}$(<"$ascii")"
fi fi
# Strip escape codes backslashes from contents of # Turn the file into a variable.
# the ascii file.
ascii_strip=$(<$ascii) ascii_strip=$(<$ascii)
# Strip escape codes backslashes from contents of
ascii_strip=${ascii_strip//\$\{??\}} ascii_strip=${ascii_strip//\$\{??\}}
ascii_strip=${ascii_strip//\\} ascii_strip=${ascii_strip//\\}