#!/usr/bin/env bash
# this is just a helper command for listing files
# it defaults to using "exa" but falls back on "ls" otherwise

# if exa is not available, start going with backup plans
if ! command -v "exa" &> /dev/null
then
    # if mac
    if [[ "$OSTYPE" == "darwin"* ]] 
    then
        # make use of BSD version
        if ! command -v "gls" &> /dev/null
        then
            ls -lAFG "$@"
        # if gnu-ls is available, use it
        else
            gls -lAF --group-directories-first --color "$@"
        fi
    # if not mac
    else
        ls -lAF --group-directories-first --color "$@"
    fi
else
    # | tac # <- is for getting folders at the bottom
    exa --color=always -lF --sort extension --group-directories-first --git --all  "$@" | tac
fi