From 9bde0eb88844c0d5bb5d0a36d26ca663587cf2b2 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 29 Jan 2016 02:03:15 +1100 Subject: [PATCH] Ascii art detection should now work on OS X --- fetch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/fetch b/fetch index 7f7c8d5f..3c4f9e7d 100755 --- a/fetch +++ b/fetch @@ -1340,9 +1340,24 @@ getascii () { if [ "$ascii" == "distro" ]; then # Get distro ascii file ascii=${ascii_distro,,} - ascii_dir="$(dirname "$(readlink -f "$0")")" + + # Use $0 to get the script's physical path. + cd "${0%/*}" + ascii_dir=${0##*/} + + # Iterate down a (possible) chain of symlinks. + while [ -L "$ascii_dir" ]; do + ascii_dir="$(readlink $ascii_dir)" + cd "${ascii_dir%/*}" + ascii_dir="${ascii_dir##*/}" + done + + # Final directory + ascii_dir="$(pwd -P)" ascii="$ascii_dir/ascii/distro/${ascii/ *}" + # Overwrite distro colors if '$ascii_color` doesn't + # equal 'distro'. if [ "$ascii_color" != "distro" ]; then c1=$(color $ascii_color) c2=$(color $ascii_color)