Thursday, January 20, 2022

list

#//////////////////////////////////////////////////////////////////////
#!/bin/bash
#//////////////////////////////////////////////////////////////////////
#----------------------------------------------------------------------
#
# list — mnemonic implementation of ls for quick listing action
#         (all lists are long and sorted by extension or time)
#
# last update 220124.1546
#  
#----------------------------------------------------------------------
#//////////////////////////////////////////////////////////////////////
# PATH AND NAME FOR FRIENDLY USE
#//////////////////////////////////////////////////////////////////////
#----------------------------------------------------------------------
_path=$0
_name="${_path##*/}"
#----------------------------------------------------------------------
#//////////////////////////////////////////////////////////////////////
# FUNCTIONS
#//////////////////////////////////////////////////////////////////////
#----------------------------------------------------------------------
#fxn() {

  # this script has no functions

#}
#----------------------------------------------------------------------
#//////////////////////////////////////////////////////////////////////
# INTERNAL AFFAIRS
#//////////////////////////////////////////////////////////////////////
#----------------------------------------------------------------------

if [ $BASH_SOURCE = "$_path" ] ; then  # script called directly

  if [[ $# -eq 0 ]] ; then # by extension

    ls -Xl
    exit 0
  fi

  if [[ "$1" = "all" ]] ; then # all files, by extension
                                
    ls -Xla
    exit 0
  fi

  if [[ "$1" = "time" ]] ; then # by time

    ls -lt
    exit 0
  fi

  if [[ "$1" = "eat" ]] ; then # all files, by time
                       
    ls -lta
    exit 0
  fi

  if [[ "$1" = "thor" ]] ; then # thorough, by extension
                                
    ls -RXl
    exit 0
  fi                         

  if [[ "$1" = "thar" ]] ; then # thorough, all files, by extension
                                
    ls -RXla
    exit 0
  fi

  if [[ "$1" = "loki" ]] ; then # thorough, by time
                                
    ls -Rlt
    exit 0
  fi

  if [[ "$1" = "laki" ]] ; then # thorough, all files, by time
                       
    ls -Rlta
    exit 0
  fi

  echo >&2
  echo $_name "    "  — by extension
  echo $_name all" "  — all files, by extension
  echo $_name time — by time
  echo $_name eat" " — all files, by time
  echo $_name thor — thorough, by extension
  echo $_name thar — thorough, all files, by extension
  echo $_name loki — thorough, by time
  echo $_name laki — thorough, all files, by time
  echo
  exit 1

fi

#----------------------------------------------------------------------
#//////////////////////////////////////////////////////////////////////
# END OF list — 220120.1400
#//////////////////////////////////////////////////////////////////////