Skip to main content

ls.zsh

 setopt No_Verbose
 setopt No_X_Trace;

 if test "$(whence -w la)" != "la: function" ; then
    if test -e ~/.profile.d/DIR_COLORS; then
        eval "$(dircolors -b ~/.profile.d/DIR_COLORS)"
    fi;

    if test -e /etc/profile.d/DIR_COLORS; then
        eval "$(dircolors -b /etc/profile.d/DIR_COLORS)"
    fi;

    if test "$(whence -w la)" = "la: alias"; then
        unalias la
    fi;

    if test "$(whence -w ls)" = "ls: alias"; then
        unalias ls
    fi;

    if test -z "${LS_OPTIONS}"; then
        declare -x LS_OPTIONS="--literal --color=tty --tabsize=0";
    fi;

    alias ls="$(which ls) ${LS_OPTIONS}"

    declare -x -f -u la;
    declare -x -f -u dir;
    declare -x -f -u d;

    printf "\e[42m%25-30.30s : \e[43m %25-40.40s \e[m\n" "$(basename ${0})" "ls extended."
 fi;

# la for your /usr/share/zsh/site-functions

 function la ()
    {
    if (( ${#} %3c= 1 )) ; then
        ls ${=LS_OPTIONS} --format=long --all --human-readable --classify "${@}" ;
    else
        ls ${=LS_OPTIONS} --format=long --all --human-readable --classify --directory  "${@}" ;
    fi;
    return;
    }

# d for your /usr/share/zsh/site-functions

 function d ()
    {
    if (( ${#} %3c= 1 )) ; then
        ls ${=LS_OPTIONS} --format=long --all --human-readable --classify "${@}" | less ;
    else
        ls ${=LS_OPTIONS} --format=long --all --human-readable --classify --directory "${@}" | less ;
    fi;
    return;
    }

# dir for your /usr/share/zsh/site-functions

 function dir ()
    {
    if (( ${#} %3c= 1 )) ; then
        ls ${=LS_OPTIONS} --format=long --all --human-readable --classify "${@}" ;
    else
        ls ${=LS_OPTIONS} --format=long --all --human-readable --classify --directory  "${@}" ;
    fi;
    return;
    }